Apologies if the subject is confusing, I hope to explain it better here.
I have a database with multiple fields and need to return information stored in it in a specific manner.
The fields are
year
date
time
headline
sub_header
content
id
boiler
sort_date
As you can see from the code below, I am displaying the information on orber by basis.
However, I would like to do the following with the output
echo "$year"; // with the year only being displayed once no matter how many results are returned
echo "$date
<br><img src=\"images/link_arrow_white.gif\" width=\"7\" height=\"7\" alt=\"\" border=\"0\"> <a href=\"show_press_releases.php?id=$id\" class=\"normal2\">$headline</a><br>
<em>$sub_header</em>
<P>";
So in effect the output would look like this
2004
<a href="show_press_releases.php?id=666" class="normal2">some text</a><br>
<em>more_text</em>
<P>
<a href="show_press_releases.php?id=666" class="normal2">some text</a><br>
<em>more_text</em>
<P>
And then change to whatever other years are present and list the rest likewise.
<?
include("db.inc.php");
$query = "SELECT * FROM press_releases ORDER BY year DESC, sort_date DESC, time DESC";
$result = mysql_query($query) or die("Nuts");
while ($row = mysql_fetch_array($result)){
$year = $row["year"];
$date = $row["date"];
$headline = $row["headline"];
$sub_header = $row["sub_header"];
$id = $row["id"];
echo "$date
<br><img src=\"images/link_arrow_white.gif\" width=\"7\" height=\"7\" alt=\"\" border=\"0\"> <a href=\"show_press_releases.php?id=$id\" class=\"normal2\">$headline</a><br>
<em>$sub_header</em>
<P>";
}
?>
PHP]