lJesterl Posted June 28, 2007 Share Posted June 28, 2007 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. Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 28, 2007 Share Posted June 28, 2007 This is a database issue you need to give the same id to each tabl e that related to each others critera. Quote Link to comment Share on other sites More sharing options...
lJesterl Posted June 28, 2007 Author Share Posted June 28, 2007 All the database stuff is correct. Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 28, 2007 Share Posted June 28, 2007 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 "; Quote Link to comment Share on other sites More sharing options...
lJesterl Posted June 28, 2007 Author Share Posted June 28, 2007 I cant do that. I want everything from groups. I then want to get everything from people WHERE groupon='$groupid' Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 28, 2007 Share Posted June 28, 2007 Simple, make a field in people table name it as gid(as in ur groups table) it will recognize a group when u search by group. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.