在下面的代码中,它显示了循环外的表行值但是在循环中没有显示。虽然循环不起作用;请让我知道它有什么不对吗?
<?php
$sql = "SELECT * FROM cl_banner ORDER BY id;";
$res = q($sql) or die(mysql_error());
if($res && mysql_num_rows($res)>0)
{
while($row = mysql_fetch_assoc($res));
{
echo $row["title"];
echo "hi";
} // End While
} // End If
?>
答案 0 :(得分:0)
<?php
$sql = "SELECT * FROM cl_banner ORDER BY id";
^^^^
$res = mysql_query($sql) or die(mysql_error());
^^^^^^^^^^
if($res && mysql_num_rows($res)>0)
{
while($row = mysql_fetch_assoc($res));
{
echo $row["title"];
echo "hi";
} // End While
} // End If
?>
答案 1 :(得分:0)
试试这个:
<?php
$sql = "SELECT * FROM cl_banner ORDER BY id";
$res = mysql_query($sql) or die(mysql_error());
if($res && mysql_num_rows($res)>0)
{
while($row = mysql_fetch_assoc($res))
{
echo $row["title"];
echo "hi";
} // End While
} // End If
?>