PDA

View Full Version : Some kind of a "group by", but different


HakkieDEV
01-15-2006, 09:11 PM
I have to following query:


$expanded_query=$DB_site->query("
SELECT forumid, threadid, COUNT(*) AS postcount FROM thread
WHERE postuserid='$myuserid'
AND open='1'
GROUP BY forumid, threadid
");
while ($row2 = mysql_fetch_array($expanded_query))
{
$grouped_postcount = $row2[postcount];
$grouped_threadid = $row2[threadid];
$grouped_forumid = $row2[forumid];
eval('$my_rows_grouped .= "' . fetch_template('my_rows_grouped') . '";');
}

However, this is not exactly what I need.

Lets say I have posted the following:

forumid = 1 -> 10 threads
forumid = 2 -> 3 threads

My current results show all 13 threads, ordered by forumid, but I would like it to "prune" it, so it will only show both of my forumid's.
Then, I would like to have it collapsable, so I could click on for example forumid1 and it would show below (expanding) my 10 threads.

I have no idea if this is a php/mysql modification or a template modification, but would appreciate if someone could help me out here.