Ok, so I have 5 tags on my front page, I want to show 5 comments related to each tag, the tags are stored in one table, and the comments in another. I have a field in the comments table called "relatedID" wich is equal to the tags table id column.
the tags are sorted by the 5 highest ranked tags from the last 20 entries into the table.
My query:
$q = mysql_query("SELECT * FROM (SELECT * FROM tags WHERE countrycode='$lang[LANGUAGE]' ORDER BY timedate DESC LIMIT 20) tmp, comments WHERE comments.related = '1' && comments.lang = '$lang[LANGUAGE]' && comments.relatedID = tmp.id ORDER BY tmp.rank ASC LIMIT 5");
while($result = mysql_fetch_array($q)) {
echo $result['tag'],'<br />';
echo $result['comment'],'<br />';
}
I want it to look like this:
Tag 1
comment 1
comment 2
comment 3
comment 4
comment 5
Tag 2
comment 1
comment 2
comment 3
comment 4
comment 5
Tag 3
And so on..
Any simple solution to this?
Now it only show up with the same tag and same 5 comments x 5 times.