RE: [PHP] i need some help with extracting data from mysql desper ately!!

From: Date: Thu, 10 May 2001 15:51:08 +0000
Subject: RE: [PHP] i need some help with extracting data from mysql desper ately!!
Groups: php.general 
Request: Send a blank email to php-general+get-52309@lists.php.net to get a copy of this message
doh! i just realised the difference in $query number, but thats not an issue in the actual code, i just cleaned that up a bit.... /sunny -----Original Message----- From: Sandeep Hundal [mailto:Sunny@mviva.net] Sent: 10 May 2001 16:49 To: 'bill'; php-general@lists.php.net Subject: [PHP] i need some help with extracting data from mysql desperately!! unfortunately, that doesn't seem to work either. it basically only gives me on name per group. here's my php: $query = "SELECT * FROM $tablename WHERE approved='yes' GROUP BY group ORDER BY group, name"; $result2 = mysql_query($query2); if ($result2) { while ($r2 = mysql_fetch_array($result2)) { extract($r2); echo " <strong>$folder</strong><br> &nbsp;&nbsp;$name <br>"; } } all it does is print out one name per group, and if there is more than one name in a group, it comes up sperately (but the group name goes missing). basically i need this: > group1 >name1 >name2 >name3 >group2 >name4 >name5 thanks for any help, i'm sure this is something really straightforward, but i can't put my finger to it.... tia! /sunny -----Original Message----- From: bill [mailto:bill@billtron.com] Sent: 10 May 2001 14:58 To: php-general@lists.php.net Subject: Re: [PHP] i need some help with extracting data from mysql Sandeep, Try: $sql="SELECT group, name FROM $tablename WHERE approved='yes' ORDER BY group, name"; Don't know what fieldname "folder" is in your original SQL. You said that the table had only id, group, & name. But I note that you must also have a fieldname called "approved". In any case, assuming the fieldnames are correct, the above should work. kind regards, bill hollett -- 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 (#52309) next »