我有一个循环,应该显示所有 MySQL 结果的摘要。它通过确定可能有多少结果然后循环多次来做到这一点。因此,如果有 43 个结果与我的查询匹配,而不是显示所有 43 个结果,它只显示第一个结果 43 次。请帮忙!这是我的代码:
if (empty($res)) {
echo 'No results found';
} else if($num>1){
echo "<b>".$num_rows."<b> results found...<br>";
while ($res = mysql_fetch_assoc($result)) {
echo "<a href='#'>{$res['dealer']}</a><br>";
}
} else {
echo "<table border=\"0\"><tr><td colspan=\"2\"><span class=\"dealer\">" . $res['dealer'] . "</span></td></tr><tr><td><span class=\"label\">Pin: </span><span class=\"inf\">" . $res['pin'] . "</span></td><td><span class=\"label\">OB CODE: </span><span class=\"ob\">" . $res['ob'] . "</span></td></tr><tr><td><span class=\"label\">Program Director:</span></td><td><span class=\"inf\">" . $res['contact'] . "</span></td></tr><tr><td valign=\"top\"><span class=\"label\">Address:</span></td><td><span class=\"inf\">" . $res['address'] . "<br>" . $res['city'] . ", " . $res['state'] . "<br>" . $res['zip'] . "</span></td></tr><tr><td><span class=\"label\">Dealer Phone:</span></td><td><span class=\"inf\">" . $res['phone'] . "</span></td></tr><tr><td><span class=\"label\">Codes Valid on:</span></td><td><span class=\"inf\">" . $res['website'] . "</span></td></tr></table>";
}
非常感谢您!