I made a php page and the output from a mysql db is as follows:
Author1
Column1
Column2
Author2
Column1
Column2
Author3
Column1
Column2
Author2
Column1
Column2
These are sorted by columndate, so author2 has a column more recent than
author3 and one less recent, so author3 is sandwiched between. I'd like to
be able to have it so that the author 'group' is only shown once. I'd prefer
it to be outputted like:
Author
Column1
Column2
Author2
Column1
Column2
Author3
Column1
Column2
If anyone could help that would be great.
This is my source code:
<?
include ('../connection.php');
$result = mysql_query("SELECT * FROM article_authors,article_columns
WHERE article_authors.authorid = article_columns.columnauth
ORDER BY article_columns.columndate DESC,article_authors.authorname
ASC",$db)
or die (mysql_error());
if ($row = mysql_fetch_array($result)) {
// display list if there are records to display
do {
$authorid=$row["authorid"];
$authorname=$row["authorname"];
$authorcollection=$row["authorcollection"];
$authoremail=$row["authoremail"];
?>
<? if ($currentauthor != $authorname) {
$currentauthor = $authorname;
?>
<?
if ($authorcollection) {
?>
<p><b><a href="columns.php?author=<?echo $authorid?>"><?echo
$authorcollection?></a></b>
</p>
<?
}else{
?>
<p><b><?echo $authorname?></b></p>
<?
}
}
$columnid=$row["columnid"];
$columndate=$row["columndate"];
$columntitle=$row["columntitle"];
$columnauth=$row["columnauth"];
$columnintro=$row["columnintro"];
list ($date_year, $date_month, $date_day) = explode ('-', $columndate);
$string = "$columndate";
$stringArray = explode("-", $string);
$date = mktime(0,0,0,$stringArray[1],$stringArray[2],$stri
ngArray[0]);
$convertedDate = date("d/m/Y", $date);
?>
»<a href="http://www.efc-online.net/articles/columns/<?echo
$columnid?>"><?echo stripslashes($columntitle)?></a>
<br><?echo stripslashes($columnintro)?> - <?echo $convertedDate?><br>
<?
} while ($row = mysql_fetch_array($result));
}
?>
If anyone could tell me how to limit the amount of times the author names
appears, i'd be most grateful.