i'm trying to show the count value from a column in my table.
my table is called ptb_forum, and it looks like this:
id | from_user_id | content | title | read_forum | deleted
1 3 hello test 20 0
2 6 bored hello 40 0
i am basically trying to get the number in read_forum (so 20 or 40 or whatever) to echo out in php by using this mysql code:
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;
}
and echoing out the result using this 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>";
} ?>
at the moment nothing is being echoed, and i dont know where im going wrong, im new to mysql and am only just learning count, can someone please show me where im going wrong. thanks
SELECT COUNT(id) AS cand use$newf['c']COUNT(id), read_forumCOUNT(id) AS read_forum