如何查看以下查询返回的行数?

mysql_select_db($database_aoldatabase, $aoldatabase);

$query1 = "select * from sale where secid  = $invoiceno ";
$query2 = "select * from sale where secid  = $invoiceno ";


$maxa = mysql_query ($query1)
    or die ("Query '$query' failed with error message: \"" . mysql_error () . '"');
$maxa2 = mysql_query ($query2)
    or die ("Query '$query' failed with error message: \"" . mysql_error () . '"');

$row = mysql_fetch_array($maxa);
$row2 = mysql_fetch_array($maxa2);

最佳答案

就像米切尔说的,做这项工作。但是,如果要使用数组处理多行,也可以使用mysql_num_rows()

$data = array();
while($row = mysql_fetch_array($maxa, MYSQL_ASSOC)) {
  $data[] = $row;
}
$count1 = mysql_num_rows($maxa);
$count2 = count($data);

关于php - PHP和MySQL:返回的行数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5140298/

10-09 20:02