gpt4 book ai didi

PHP 和 MySQL : Number of rows returned

转载 作者:行者123 更新时间:2023-11-29 01:08:15 24 4
gpt4 key购买 nike

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

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()

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

关于PHP 和 MySQL : Number of rows returned,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140298/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com