新浦京娱乐场官网:PHP MYSQL mysql_fetch_object - 从查

2019-06-16 02:08栏目:技术创新

mysql_fetch_object语法:

array mysql_fetch_object (resource $Result_Set)

                                Result_Set句柄返回一个mysql_query查询结果集。

如果执行成功返回包含了所有数据行的object,如果失败则返回bool值

下面是演示代码:

<?php
$UserName = 'abc';
$Password = '1234';
$DbHandle = mysql_connect ('localhost', $UserName, $Password);
if (!$DbHandle) {
  die 'No database connection could be established.';
}

$DBName = 'w3db;
if (!mysql_select_db ($DBName, $DbHandle)) {
  die 'Database could not be selected.';
}
$Query = "SELECT ISBN, Title, Author FROM articles";
$articles = mysql_query ($Query, $DbHandle));

while ($Row = mysql_fetch_object ($articles)) {
  echo "ISBN = $Row->ISBN<br />n";
  echo "Title = $Row->Title<br />n";
  echo "Author = $Row->Author<br />n";
}

?>

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:新浦京娱乐场官网:PHP MYSQL mysql_fetch_object - 从查