Can anyone please tell what I am doing wrong or missing in this query? I am trying to get the attachments count per forum and right now it shows the same count and bytes in every forum. Here is the code:
PHP Code:
/** Count of Attachments Per Forum and Bytes **/
$attachs=$DB_site->query_first("SELECT forum.title AS forum, COUNT(attachment.attachmentid) AS count, SUM(LENGTH(attachment.filedata)) AS bytes
FROM attachment,post,thread,forum
WHERE attachment.attachmentid = post.attachmentid
AND post.threadid=thread.threadid
AND forum.forumid=thread.forumid
GROUP BY thread.forumid
ORDER BY count DESC");
$attachs['count'] = number_format($attachs['count']);
$attachs['bytes'] = number_format($attachs['bytes']);
/** Count of Attachments Per Forum and Bytes **/