PHP查询语句,如何返回总记录数??13
发布网友
发布时间:2023-10-30 06:08
我来回答
共5个回答
热心网友
时间:2024-12-05 19:51
PHP查询语句,有两种方法获得查询的总记录数。
一是使用mysql_num_rows函数,例子代码:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);
echo "$num_rows Rows\n";
?>
二是修改查询语句,使用COUNT(*)作为查询内容,例子代码:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT COUNT(*) FROM table1", $link);
list($num_rows) = mysql_fetch_row($result);
echo "$num_rows Rows\n";
?>
热心网友
时间:2024-12-05 19:52
$total = mysql_num_rows($sqlBBS1); 括号里面要加个参数才对。。。这样就可以了
热心网友
时间:2024-12-05 19:52
mysql_num_rows返回总数
<?php
$sqlBBS1=mysql_query("select * from wenzhang where wz_fenlei='".$row_BBS1['st_xbk']."' and wz_xxid='".$row_xuexiao['xx_id']."' ORDER BY wz_id DESC");
$re_num = @mysql_num_rows($sqlBBS1);
$sqlBBS1=mysql_fetch_array($sqlBBS1);
?>
$re_num返回的就是总数
热心网友
时间:2024-12-05 19:53
$total = mysql_num_rows();追问Warning: Wrong parameter count for mysql_num_rows() in
热心网友
时间:2024-12-05 19:53
count一下