473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.
Jul 16 '05 #1
0 1503

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
4
by: Richard Tierney | last post by:
To create help output (the response to "myprog --help", for example) I currently create a big .h file, which includes a single string, such as: static char *help_text = "\ myprog: my program\n\...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
13
by: Fao | last post by:
Hello, I am having some problems with inheritance. The compiler does not not return any error messages, but when I execute the program, it only allows me to enter the number, but nothing else...
8
by: wastedhello | last post by:
ok. here are a list of things i cant fix. ive been trying for way to long now. 1. if more then 1000 values are told, will still continue with program. 2. if -max, min, average etc run, and 2...
2
by: cJ500 | last post by:
I can't figure out the problem with this code. I'm using a Borland compiler. The problem is with the / operation overload. When I call isNeg it doesn't output true or false. Now I know this code...
3
by: RedRoses | last post by:
Hey guys i really need ur help in my C++ assignment , its very hard 4 me coz its the first time 4 me to take a course in programming or anything related to computer !!! :s so plzzzzzzzzz help me...
3
by: Stephen Torri | last post by:
Below is a class that is suppose to represent a segment of memory or a contents of a binary image (e.g. ELF executable). I have started to read Modern C++ Design and thought the best way to ensure...
4
by: rsaharia | last post by:
Hello All, I need help with this particular .pl file I picked up from http://www.veritools-usa.com/xnf2vhdl.htm What it's supposed to do is really convert an xnf file to a vhdl file. I need it for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.