您好我有以下代码显示安特里姆郡内的所有高尔夫球场:
<?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: " . $info["club_name"] . "<br />";
Echo "County: " . $info["county"] . "<br />";
Echo "To read more information on this golf club and course " . $info["description"];
Echo "</div>";
}
?>
有人能告诉我之前我可以使用的查询来显示所显示的结果数量。例如“在这个县显示38个高尔夫球杆” - 但结果是使用php计算的?
提前致谢:)
答案 0 :(得分:0)
这样做
$count = mysql_num_rows($data);
echo "Showing ". $count. " golf clubs in this County";
答案 1 :(得分:0)
我认为mysql_num_rows($resource)
会做到这一点。这是你要的吗?