Jump to content

list question


lJesterl

Recommended Posts

im trying to do something and i cant figure out how to get it to list properly. Basicly I have 2 tables one called groups with 2 rows gid and gname and one called people with 3 rows pid, pname, and groupon

 

by doing this

 



$listgroups=mysql_query("SELECT gid,gname FROM groups ORDER by gname");
while(list($gid,$gname)=mysql_fetch_row($listgroups)){

$grouplist=$grouplist."
$gname
";
}

echo " $grouplist ";


 

I can get it to list like this:

 

 

[ Group A ]

 

[ Group B ]

 

 

I need to go even farther and have it get the names of the pname from people with the groupon being that group id. Let say John Doe Belongs to group A and group a's id is 1 and johndoe has groupon 1 in mysql. How would I also list everyone that has groupon to the coresponding group like so:

 

[ Group A ]

John Doe

James

Kyle

etc.

 

[ Group B ]

Sam

Bill

Ted

etc.

Link to comment
Share on other sites

example where the name table matches the username.

 

$listgroups=mysql_query("SELECT gid,gname FROM groups where  name='user_name' ");
while(list($gid,$gname)=mysql_fetch_row($listgroups)){

$grouplist=$grouplist."
$gname
";
}

echo " $grouplist ";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.