MysqL_num_fields用于获得查询结果的列数,如果执行成功返回列数,执行失败,返回boolean值
/**
* PHP MysqL – 根据查询获得结果的列数和行数
*
* @param
* @arrange 512-笔记网: jb51.cc
**/
<?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));
$RowCount = MysqL_num_rows ($articles);
$FieldCount = MysqL_num_fields ($articles);
$I = 0;
while ($I < $RowCount) {
$Row = MysqL_fetch_assoc ($articles);
echo "Row $I<br />\n";
$J = 0;
while ($J < $FieldCount) {
echo "$Row[$J]<br />\n";
++$J;
}
++$I;
}
MysqL_close ($DbHandle);
?>
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528432.html