我在我的論壇網站的評論列表中有問題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