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. Link to comment https://forums.phpfreaks.com/topic/57519-list-question/ 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. Link to comment https://forums.phpfreaks.com/topic/57519-list-question/#findComment-284631 Share on other sites More sharing options...
lJesterl Posted June 28, 2007 Author Share Posted June 28, 2007 All the database stuff is correct. Link to comment https://forums.phpfreaks.com/topic/57519-list-question/#findComment-284633 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 "; Link to comment https://forums.phpfreaks.com/topic/57519-list-question/#findComment-284636 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' Link to comment https://forums.phpfreaks.com/topic/57519-list-question/#findComment-284638 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. Link to comment https://forums.phpfreaks.com/topic/57519-list-question/#findComment-284640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.