0
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;
}
這是我的職責。不能從SQL查詢getted元素添加到陣列
我用它從其他文件
foreach (get_comment_count_for_events() as $comment_count_event) {
echo $comment_count_event['tiken_event'];
echo $comment_count_event['count'];
}
但databese當我測試查詢它的工作: 結果: event_token - 計數
1 - 13
2 - 13
8 - 11
3 - 8
5 - 7
7 - 4
6 - 3
'' - 0
而($行= mysql_fetch_array(-----我的失誤---- $結果------)){ – user2022879
是的,有一個的錯誤 –