PHP 和 MySQL:返回的行数
如何查看以下查询返回多少行?
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);
How can I see how many rows the following query returns?
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);
正如 Michiel 所说,
mysql_num_rows()
可以完成这项工作。但是,如果您想使用数组处理多行,也可以使用count()
。Like Michiel said,
mysql_num_rows()
do the job. But if you want to work with more than one rows using an array, you can usecount()
too.