我在我的论坛网站的评论列表中有问题php 请帮忙 我试图循环所有的用户评论,但它只出现1或失败循环显示所有相同的评论很多号码。如何循环php的变量
<?php
include 'connection.php';
echo '<table border="1" bgcolor="#FBFBEF" width="100%" height="20"><tr>';
echo '<td width="80%" height="20"><strong>Thread :';
$query="select title from topic where topic_id=".$_REQUEST['topic'];
$result=mysql_query($query);
$row=mysql_fetch_array($result);
echo $row['title'];
if($row){
do{
echo'</strong></td><td align="center" valign="top"><strong><?php ';
$query2="select * from comment where topic_id=".$_REQUEST['topic'];
$result2=mysql_query($query2);
$row2=mysql_fetch_array($result2);
echo $row2['post_date'];
echo '</strong></td></tr></table>';
echo '<table border="1" bgcolor="#FBFBEF" width="100%" height="20"><tr><td align="center" valign="top" height="20"><strong> Post By :<strong></td><td width="85%" ><strong>';
echo $row['title'];
echo'</strong></td></tr>';
echo '<tr><td align="center" valign="top"><strong>';
$query3="select * from user_login where email='".$row2['post_by_user']."'";
$result3=mysql_query($query3);
$row3=mysql_fetch_array($result3);
echo '<br>'.$row3['first_name'].' '.$row3['last_name'];
echo '</strong></td><td align="left" valign="top" height=200>';
//displaying list comment
echo '<p>'.$row2['description'].'</p><hr>';
}while($row=mysql_fetch_array($result2));
}
?>
</td>
</tr>
为什么循环失败?
'$行= mysql_fetch_array($结果2)'是不是一个比较? – 2014-12-05 03:28:53
你在错误的地方循环着非相关的变量。注意:你很容易SOL注入和使用折旧的mysql_ *函数 – bansi 2014-12-05 03:31:42
可以修复它吗? :d – 2014-12-05 03:40:20