I'm planning to try a few approaches to pulling out information from a MySQL database using PHP that will break things down into groups according to year - it's for an art gallery archive.
Each group of results will have the year displayed top left (only once), then on the right the list of artists who exhibited in that year going down.
So far I have a series of arrays like this:
Probably not the most elegant way of doing this, but it's a starting point. My problem is that it isn't showing the year even though there are results.
Any ideas why?
I can't hard code the year into each array because I want any year with no results to be ignored - so it doesn't mess up the vertical spacing
thanks
Steve
Each group of results will have the year displayed top left (only once), then on the right the list of artists who exhibited in that year going down.
So far I have a series of arrays like this:
HTML:
<div id="archive_text">
<?php
$sql = 'SELECT * FROM exhibitions WHERE archive="yes" AND year="2009" ORDER BY year DESC, month DESC';
$result = mysql_query($sql) or die(mysql_error());
?>
<div id="archive_year"><?php echo $row['year']; ?></div>
<div id="archive_event">
<?php
while($row = mysql_fetch_assoc($result)) {
?>
<a href="exhibitions/index.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a><br />
<?php } ?>
</div>
</div>
Probably not the most elegant way of doing this, but it's a starting point. My problem is that it isn't showing the year even though there are results.
Any ideas why?
I can't hard code the year into each array because I want any year with no results to be ignored - so it doesn't mess up the vertical spacing
thanks
Steve