0

嗨,我有以下代码来显示安特里姆郡内的所有高尔夫球场:

<?php

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("golf_locate") or die(mysql_error());
$data = mysql_query("SELECT * FROM golf_courses WHERE county = 'Antrim'")
or die(mysql_error());

$image = "golfimage.jpg";

while($info = mysql_fetch_array( $data ))
{
Echo "<div id='image'><img src=".$image.">" . "<br />" . "</div>";
Echo "<div id='text'>";
Echo "Golf Club:&nbsp;" . $info["club_name"] . "<br />";
Echo "County:&nbsp;" . $info["county"] . "<br />";
Echo "To read more information on this golf club and course " . $info["description"];
Echo "</div>";
}

?>

谁能告诉我在它之前可以使用的查询来显示显示的结果数量。例如“在这个县显示 38 个高尔夫俱乐部” - 但结果是使用 php 计算的?

提前致谢 :)

4

2 回答 2

0

做这个

   $count = mysql_num_rows($data);

   echo "Showing ". $count. " golf clubs in this County";
于 2013-05-12T16:37:56.360 回答
0

我想mysql_num_rows($resource)会做到的。这是你要求的吗?

于 2013-05-12T16:38:20.263 回答