Hey everyone,
I have a page on my website which displays all photo galleries submitted by all users with a maximum of 12 on each page ordered by date (with page numbers and prev/next links to go to the other pages). Some users have a ridiculously large number of galleries, so i only ever want to display a maximum of 3 galleries per user in the results list and (if the user does have more than 3) a little banner saying click here to view their remaining galleries.
I was wondering if there is anyway of getting the final gallery list in one mysql query? I currently have
$query = "SELECT $table.* FROM $table WHERE FZipExclusive='0' ORDER BY FDateUpdated DESC";
Which obviously returns all galleries ordered by date. I could do:
$query = "SELECT * FROM $table WHERE FZipExclusive='0' GROUP BY FUsername ORDER BY FDateUpdated DESC";
Which displays one gallery for each user and orders it by date.
Is there anyway of doing a similar thing to what's above, however displaying the first 3 galleries for each user (ordered by date ideally) .
I appreciate i could do it quite easily by using mulitple queries, or processing the results in php, but i would much rather do it in one mysql query if possible?
Thanks so much for your help,
Dave