function get_comment_count_for_events() {
$query = "SELECT event_token , COUNT(NULLIF(event_token, '')) AS counts FROM comment GROUP BY event_token ORDER BY counts DESC;";
$result = mysql_query($query);
$comment_count = array();
while ($row = mysql_fetch_array($query)) {
$comment_count = $row;
}
if (!$result) {
trigger_error('Invalid query: ' . mysql_error() . " in " . $query);
}
return $comment_count;
}
This is my function.
I use it from other file
foreach (get_comment_count_for_events() as $comment_count_event) {
echo $comment_count_event['tiken_event'];
echo $comment_count_event['count'];
}
But in databese when i test query it's work: result: event_token - counts
1 - 13
2 - 13
8 - 11
3 - 8
5 - 7
7 - 4
6 - 3
''- 0