mysql_select_db($database_QASite, $QASite);
$query_getUpperMenu = "SELECT * FROM topic WHERE is_top=1";
$getUpperMenu = mysql_query($query_getUpperMenu, $QASite) or die(mysql_error());
<?php do {
if(isset($row['title'])){
echo mysql_num_rows($getUpperMenu);//This prints 2
?>
<li class="NOSEPARATOR"><a href="?topic_id_header=<?php echo $row['topic_id']; ?>"><?php echo $row['title']; ?></a></li>
<?php
}
} while ($row = mysql_fetch_assoc($getUpperMenu));
?>
仅打印一次迭代
我在数据库中有2个结果..但迭代只继续一次,..为什么会这样?
更新:
<ul id="Menu1" class="MM" style="position:absolute; left: 20px; top: -27px;" >
<?php while ($row = mysql_fetch_assoc($getUpperMenu)) {
echo mysql_num_rows($getUpperMenu);//prints 2
?>
<li class="NOSEPARATOR"><a href="?topic_id_header=<?php echo $row['topic_id']; ?>"><?php echo $row['title']; ?></a></li>
<?php
}
?>
答案 0 :(得分:0)
尝试使用mysql_fetch_array而不是mysql_fetch_assoc。