RE: [PHP-DB] Re: Retrieving data woes

From: Date: Mon, 10 Dec 2001 20:32:23 +0000
Subject: RE: [PHP-DB] Re: Retrieving data woes
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-14913@lists.php.net to get a copy of this message
Thanks to Hugh and DL Neil for their answers. I got it working now with your help. Makes me feel dumb now! -- Andrés > > In your SQL request, sort by date. When printing the output, > keep track of the previous date - only print the date if it > changes. Something like > > $conn = mysql_pconnect($host, $usr, $pwd); > mysql_select_db("mydb"); > $sql = "SELECT id,date,time,title,body FROM mytable ORDER > BY date DESC"; > $res = mysql_query($sql); > > $date = "previous date"; > while($row = mysql_fetch_array($res)) { > if ($date != $row["date"]) { > $date = $row["date"]; > echo "<br>$date"; > } > > echo "<p>".$row["time"]." > ".$row["title"]; > echo "<br>".$row["body"]; > } > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.db (#14913) next »