我應該在帖子正文中顯示評論數字。但後身是在while,如果我把評論num查詢,而頁面,而是沉重!如何將查詢放在一邊,但我們在一邊嗎?
我想要做的,但不工作:
$comments_data = mysql_query("SELECT * FROM `comments` WHERE `blogid`='$bid' AND `postid`='$postid'") or die(mysql_error());
$coments_num = mysql_num_rows($comments_data);
if($post_query) {
while($post_data = mysql_fetch_array($post_query)) {
$postid = $post_data['id'];
$post_temp = $post;
$post_temp = str_replace('[post_comments]',$coments_num,$post_temp);
$posts .= $post_temp;
}
}
但如果我用這樣將工作:(!但到多少查詢)
if($post_query) {
while($post_data = mysql_fetch_array($post_query)) {
$postid = $post_data['id'];
$comments_data = mysql_query("SELECT * FROM `comments` WHERE `blogid`='$bid' AND `postid`='$postid'") or die(mysql_error());
$coments_num = mysql_num_rows($comments_data);
$post_temp = $post;
$post_temp = str_replace('[post_comments]',$coments_num,$post_temp);
$posts .= $post_temp;
}
}
我的問題就在這裏!該查詢是在同一時間!巫婆意味着會有這麼多的疑問! – user1968224
只是使用加入我的答案,檢查演示 – Asgaroth
tnx,但我認爲你不明白!評論在另一張桌子! – user1968224