I have been struggling with this code a while. The code lists artists and curators for exhibits for a specific gallery (GET $id), but I'm having trouble grouping the artists. It works almost fine when there are no curators attached to the exhibit, but as soon as there are curators it mixes the output. Here is an example that shows what I mean: http://norwegianartyearbook.no/the_list/gallexh.php?id=190Artists from exhibits with curators are shown in bold.How can I group the list of artists so the curators will be shown at the end? I did try to make a loop inside the loop but with no luck.

Either the Artist or Curator or Both fields may be blank (LEFT JOIN).If both fields are NOT blank, make the Artist bold. (This requisite nullifies the ability to GROUP BY)Output: <Headers><Artist List><Curator List>

This is of course assuming you intend for exhibit x artist x curator, and not exhibit x artist, exhibit x curator.

hoeiesta
—
2012-02-27T14:14:12Z —
#3

Thank you,

Is it a typo when you're saying "output_curator_array" in the first loop - you mean "output_artist_array", right? This loop is supposed to end when the curator array is empty and output exhibit details plus the artist list (not in bold to show first loop).

The second loop is where the problem lays, I think. If neither artist nor curator are empty it's supposed to output both a list of artists and a list of curators. First the artists, then the curators.If I understand correct you're saying it only outputs one artist name (in bold), then the curator_array - and the loop continues?How can I continue the loop after the first artist to get a list of all artists, and then add the curator_array?

All exhibits will have at least one artist but might not have any curators OR as many as wanted.

Thank you for helping!

StarLion
—
2012-02-27T14:26:15Z —
#4

Nope.

Programming Trick - just because something is at the top of a loop, doesnt mean it's executed first.There's only one loop. Because there's only one set of data.the first IF triggers whenever a new exhibit is detected. (you should be sorting your query on exhibit)The second IF triggers if this ISNT the first entry into the loop.I meant it exactly the way it's written, with one addition. It should have had an additional entry though.

"output additional seperator" should come after empty curator_array.

hoeiesta
—
2012-02-28T12:57:44Z —
#5

Thank you. I think I understand what you mean by "sort query by exhibit" but I don't know how to set up the first IF, Row[exhibit].And what's the difference between output and echo?

The $result_final loop from my first code should be removed now since this loop will do the same, right?

Here is my new code that show artist names and exhibit details (Header?) no curators result (still the same link as above):