Martin: [PHP] How? :)

From: Date: Wed, 30 Jan 2002 03:23:23 +0000
Subject: Martin: [PHP] How? :)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-82662@lists.php.net to get a copy of this message
Martin, Are you guys getting yours by email or monitoring a newsgroup reader? John Works wonderfully:) http://DELETETHISccl.flsh.usherb.ca/bookmarks/DELETETHIS Martin Towell wrote: > ---------------------------------------------------------------------- > $news = mysql_query("select * from bookmarks ORDER by TNum,AU asc"); > $old_TNum = ""; > while ($mydata = mysql_fetch_object($news)) > { > if ($old_TNum != $mydata->TNum) #when TNum occurs the first time, echo > it once only. > { > $old_TNum = $mydata->TNum; > $body .= "<b>".$mydata->TNum.":</b>"; > } > $body .= "<li>".$mydata->AU."</li>"; > } > ---------------------------------------------------------------------- > > tada!! > > Martin > > -----Original Message----- > From: jtjohnston [mailto:jtjohnston@courrier.usherb.ca] > Sent: Wednesday, January 30, 2002 2:05 PM > To: php-general@lists.php.net > Subject: [PHP] How? :) > > Let's say I have two fields TNum and AU. > > TNum is a <select><option>British<option>American<option>Canadian > AU <input> name of an author. I want to sort them as follows. > > British > Shakespeare > American > Joyce > Samuels > Twain > Canadian > Majors > Kamboureli > > How do I get this to work in this code below? > I want to echo TNum one time only and echo every AU. > > $news = mysql_query("select * from bookmarks ORDER by TNum,AU asc"); > while ($mydata = mysql_fetch_object($news)) > { > if (...??) #when TNum occurs the first time, echo it once only. > { > $body .= "<b>".$mydata->TNum.":</b>"; > } > $body .= "<li>".$mydata->AU."</li>"; > } > ---------------------------------------------------------------------- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#82662) next »