$news = mysql_query("select * from bookmarks ORDER by TNum,AU asc");
$old_TNum = "";
while ($mydata = mysql_fetch_object($news))
{
  $new_TNum = $mydata->TNum;
  if ($new_TNum != $old_TNum) #when TNum occurs the first time, echo it once
only.
  {
    $old_TNum = $new_TNum;
    $body .= "<b>".$temp.":</b>";
  }
  $body .= "<li>".$mydata->AU."</li>";
}

-----Original Message-----
From: jtjohnston [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 14:05
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to