如何使用php mysql函数获取总行数?

如何使用php mysql函数获取总行数?,php,mysql,Php,Mysql,如何使用php mysql函数获取总行数 我使用此代码显示mysql中的数据。很好 Buy我想知道我能用这个代码得到行的总数吗 <?PHP include("connect.php"); $query = "SELECT * FROM table"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $id = $row['id']; } ?

如何使用php mysql函数获取总行数

我使用此代码显示mysql中的数据。很好

Buy我想知道我能用这个代码得到行的总数吗

<?PHP
include("connect.php");
$query = "SELECT * FROM table";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
    $id = $row['id'];
}
?>


试试这个
mysql\u num\u rows($result)
试试这个
mysql\u num\u rows($result)
使用这行代码

<?PHP
include("connect.php");
$query = "SELECT * FROM table";
$result = mysql_query($query) or die(mysql_error());
$number_of_rows = mysql_num_rows($result); // this will return the number of rows found by the $result query. 
echo $number_of_rows;
while($row = mysql_fetch_array($result))
{
    $id = $row['id'];
}
?>

使用这行代码

<?PHP
include("connect.php");
$query = "SELECT * FROM table";
$result = mysql_query($query) or die(mysql_error());
$number_of_rows = mysql_num_rows($result); // this will return the number of rows found by the $result query. 
echo $number_of_rows;
while($row = mysql_fetch_array($result))
{
    $id = $row['id'];
}
?>