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:[EMAIL PROTECTED]]
Sent: 10 May 2001 16:49
To: 'bill'; [EMAIL PROTECTED]
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:[EMAIL PROTECTED]]
Sent: 10 May 2001 14:58
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
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