0
我試圖顯示在某個發佈頁面中所做的所有評論。所有變量調用都可以正常工作(包括函數timeago),但它只顯示第一個註釋。mysql_fetch_assoc在While循環中顯示一條記錄
$com_sql = "SELECT comments.com_id,
comments.com_topic,
comments.com_user,
comments.com_content,
comments.com_date,
users.userid,
users.username,
users.usernombre,
COUNT(com_topic) AS com_top
FROM comments
LEFT JOIN users
ON comments.com_user = users.userid
WHERE com_topic = " . mysql_real_escape_string($_GET['id']) . "
GROUP BY com_topic
ORDER BY com_id DESC";
$com_result = mysql_query($com_sql);
if(!$com_result)
{echo 'The COMMENTS table could not be displayed.';}
else
{ if(mysql_num_rows($com_result) == 0){ echo 'No comments yet!';}
}
// Now I should show them one by one:
// Should $com_row be com_top??
while($com_row = mysql_fetch_assoc($com_result))
{ echo '<table width="100%" height="253" border="4">
<tr><td width="9%" rowspan="2" valign="top"><p>IMG</p>
<p>editar</p><p> </p><p> </p></td><td width="63%">';
$com_user = stripslashes($com_row['username']);
$com_usernombre = stripslashes($com_row['usernombre']);
echo $com_user;
echo $com_usernombre;
echo '</td><td width="4%" height="24"><div align="right"> <p>PM</p>
</div></td><td width="24%"><div align="right">';
$referencedate = strtotime($com_row['com_date']);
$result = timeago($referencedate);
echo 'Ago';
echo $result ;
echo '</div></td></tr><tr><td colspan="3" valign="top">';
$com_content = stripslashes($com_row['com_content']);
echo $com_content;
echo '</td></tr>';
}
echo '</table>';
我使用我的網頁的其他部分相同的模板和他們很好地工作: -/ 我在做什麼錯? COUNT很好嗎?我是否正確使用while($ com_row = mysql_fetch_assoc($ com_result))? 希望你能幫助我:-)
THANKS
YAY !!!你是個了不起的男孩!我花了整整一天的時間來解決這個問題,但花了10秒鐘才發現: - /感謝李! – cbarg