我想顯示從我的表中的列的計數值。從mysql列顯示計數值?
我的表稱爲ptb_forum,它看起來像這樣:
id | from_user_id | content | title | read_forum | deleted
1 3 hello test 20 0
2 6 bored hello 40 0
我基本上嘗試使用此MySQL來獲得read_forum(所以20或40或其他)的數量在PHP呼應出代碼:
function check_new_forum2() {
global $connection;
global $_SESSION;
$query = "SELECT COUNT(id) read_forum FROM ptb_forum WHERE ptb_forum.read_forum=ptb_forum.from_user_id AND ptb_forum.deleted='0'
";
$check_new_forum_set2 = mysql_query($query, $connection);
confirm_query($check_new_forum_set2);
return $check_new_forum_set2;
}
,並使用這個PHP呼應出來的結果:
$check_new_forum_set2 = check_new_forum2();
while ($newf = mysql_fetch_array($check_new_forum_set2)) {
echo "<div class=\"forum_comments\">". $newf['COUNT(id)'] ." Views</div>";
} ?>
在n時刻沒有正在迴應,我不知道我會出錯哪裏,即時通訊新的MySQL,我只是在學習計數,有人可以告訴我哪裏會出錯。 謝謝
mysql_ *是depricated請不要依靠他們 – 2013-03-14 01:24:46
'選擇COUNT(id)AS c'並使用'$ newf ['c']' – 2013-03-14 01:25:32
COUNT(id),read_forum – 2013-03-14 01:25:56