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):
PHP Code:
$result_array = array();
$counter = 0;
// List of exhibits per gallery
$row = 1;
$result = mysql_query(
"SELECT p.id
, p.title
, p.info
, p.galleryid
, p.start_date
, p.end_date
, p.date
, a.id
, a.aname
, a.exhibitid
, k.id
, k.cname
, k.exhibitid
FROM exhibit AS p
LEFT JOIN artist AS a ON p.id=a.exhibitid
LEFT JOIN curator AS k ON p.id=k.exhibitid
WHERE p.galleryid='$id'
ORDER BY p.start_date, a.id asc" );
$saveTitle = '';
$saveArtist = '';
$saveCurator = '';
// initialize the variables used for checking any changes
while ($list = mysql_fetch_array($result)) {
$exhibit = '';
$artists = '';
$curators = '';
$title = $list['title'];
$info = $list['info'];
$date = $list['date'];
$art = $list['aname'];
$cur = $list['cname'];
$start = $list['start_date'];
$end = $list['end_date'];
$timestamp = strtotime($start);
$start = date("d.m.y",$timestamp);
$timestamp = strtotime($end);
setlocale(LC_TIME, "no_NO.ISO_8859-1");
$end = date("d.m.y",$timestamp);
// check if the exhibit name has changed. If it did, display the exhibit info and save the new exhibit name
if ($title != $saveTitle) {
// display exhibit info
$exhibit = "<span class='gallinfo'></p>$start-$end </span><span class='galltitle'>$title </span><span class='gallinfo'><em>$info </em></span><br /><span class='gallinfo'>Artists: </span>";
// save new exhibit name
$saveTitle = $title;
if (! empty($exhibit)) {
// display curators
echo $curators;
unset($curators);
}
echo $exhibit;
}
if (! empty($art)) {
if (! empty($cur)) {
echo "<b>$art, </b>";
// display curators
$curators = "<span class='gallinfo'>Curator: $cur,</span>";
$saveCurator = $cur;
}
else {
echo "$art, ";
}
}
}
Bookmarks