Associate
- Joined
- 29 May 2003
- Posts
- 2,038
- Location
- Cambridge
Probably just cause it's Friday and I'm knackered, but this has got me stumped ...
A client wants to show a list of the awards they've received over various years, and they want to be able to add future awards themselves, so the MySQL database fields I'm using consist of:
awardid (primary key)
year (stored as a year object in MySQL)
title (the name of the award - varchar object, max. 100 characters)
link (optional field containing a link to a detail page - varchar, max. 25 characters)
My SELECT query is:
When I display them on the page I'm using the following:
It works fine in that it displays the data correctly in the format that I want, apart from the fact that for one year they got two awards. The <h2> head repeats, which looks a bit naff.
Is there any any simple way of stopping the <h2> from repeating if two or more consecutive records retrieved from the database have the same year - the idea being that the year heading in the <h2> will appear only once? Might not have explained that very well, so this might be clearer:
<h2>2001</h2>
((name of award))
((name of award))
<h2>2003</h2>
((name of award))
<h2>2004</h2>
((name of award))
I'm sure this is easier than I'm making it out to be - it's time I wasn't here and my brain has given up for the day ... any ideas or suggestions?
A client wants to show a list of the awards they've received over various years, and they want to be able to add future awards themselves, so the MySQL database fields I'm using consist of:
awardid (primary key)
year (stored as a year object in MySQL)
title (the name of the award - varchar object, max. 100 characters)
link (optional field containing a link to a detail page - varchar, max. 25 characters)
My SELECT query is:
Code:
SELECT awards.`year`, awards.title, awards.link FROM awards ORDER BY awards.`year` ASC
Code:
<?php do { ?>
<h2 class="pr"><?php echo $row_rsAwards['year']; ?></h2>
<p><?php echo $row_rsAwards['title']; ?></p>
<?php if ($row_rsAwards['link'] != "None") {echo '<p align="right"><a href="'.$row_rsAwards['link'].'">Show me the development ></a></p>';} ?>
<?php } while ($row_rsAwards = mysql_fetch_assoc($rsAwards)); ?>
Is there any any simple way of stopping the <h2> from repeating if two or more consecutive records retrieved from the database have the same year - the idea being that the year heading in the <h2> will appear only once? Might not have explained that very well, so this might be clearer:
<h2>2001</h2>
((name of award))
((name of award))
<h2>2003</h2>
((name of award))
<h2>2004</h2>
((name of award))
I'm sure this is easier than I'm making it out to be - it's time I wasn't here and my brain has given up for the day ... any ideas or suggestions?