Nope,

Do a select like so:

Select user_name, group_name from users,groups where
users.group_id=groups_id order by group_name;


Then do a php loop (you'll need to find the eact php commands, this is just
an example):

While (!$results->EOF)
{

If ($results[group_name]!="$old_groupname")
{
        $old_groupname=$results[group_name];
        print "<TR><TD>$old_groupname</td><td>&nbsp;</td></tr>";
}else
{
        print "<TR><TD>&nbsp;</td><TD>$results[user_name]</td></tr>";
}
$results=mysql_fetch_array($sql);
}

You'll obviously need to get exact mysql commands etc, and open and close
your table outside the loop, but this should be basically it.


Thanks

Mark


-----Original Message-----
From: Rankin, Randy [mailto:[EMAIL PROTECTED]] 
Sent: 23 September 2002 13:37
To: '[EMAIL PROTECTED]'
Subject: [PHP] Confused


I have two MySQL tables, groups and users:

        groups: group_id, group_name

        users: user_id, user_name, group_id, etc.

I would like to produce one table for each group which will list all the

members for that particular group. For example:

    Blue (group_id 1)

        Tom (group_id 1)

        Nancy (group_id 1)

        Jim (group_id 1)

    Red (group_id 2)

        Bob (group_id 1)

        Susan (group_id 1)

        James (group_id 1)

...

My question is, do I need to run 2 queries? The first to select all the

groups and the second to select all the users in each group based on the

group_id? How would I loop through to create a table for each group? 

Thanks in advance for any help.

Randy Rankin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to