Help with output

This is a discussion on Help with output within the PHP Language forums, part of the PHP Programming Forums category; I made a php page and the output from a mysql db is as follows: Author1 Column1 Column2 Author2 Column1 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-07-2003
Louis
 
Posts: n/a
Default Help with output

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);

?>

&raquo;<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.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:57 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0