contra10 Posted December 23, 2008 Share Posted December 23, 2008 Hi, I jusst need to know where to start. I have the group pages set up and a join group button, how do i make a member enter a group and then echo that group name in the profile Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/ Share on other sites More sharing options...
contra10 Posted December 23, 2008 Author Share Posted December 23, 2008 should values be put in seperate table? Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-721981 Share on other sites More sharing options...
MadTechie Posted December 23, 2008 Share Posted December 23, 2008 Okay its 4am so i'm about to get some shut eye.. but i would have the users table ie UserID - Name - email 1 - Admin - ME@me.com 2 - John - john@me.com 3 - Sam - sam@me.com 4 - Paul - paul@me.com a Groups Table ie GroupID - Name 1 - Admins 2 - Users 3 - Noobs then a third table to join them UserID - GroupID 1 - 1 2 - 3 4 - 3 3 - 2 3 - 3 Soo User = Group Admin = Admins John = Users Sam = Users Paul = User & Noob then an SQL like SELECT Users.*, Groups.Name FROM Users JOIN UserGroups ON UserGroups.UserID = Users.ID JOIN Groups ON Groups.id = UserGroups.GroupID Where Users.ID = $UserID If you only want 1 group per used then just add an extra field in the users table to hold the Group ID then alter your SQL statment like so current SELECT * FROM Users Where ID = $UserID SELECT Users.*, Groups.Name FROM Users JOIN Groups ON Groups.id = Users.GroupID Where Users.ID = $UserID assuming the added to users field was called GroupID Hope that helps EDIT: corrections .. but its probably still wrong.. ahh bed is calling Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-721990 Share on other sites More sharing options...
contra10 Posted December 23, 2008 Author Share Posted December 23, 2008 thanks for trying but it doesnt work...and at the same time my users information is stored in a different database and the group inforation is in a different dataase, should i store the group information in a different table in the same database? I'm trying to make it that so a user joins a group and when he/she joins the group name is echoed in their profile and in the group members Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722408 Share on other sites More sharing options...
redarrow Posted December 23, 2008 Share Posted December 23, 2008 Paul = User & Noob <<<<<<<, that made my day happy xmas m8. Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722419 Share on other sites More sharing options...
redarrow Posted December 23, 2008 Share Posted December 23, 2008 Why do you all do it so hard. just add a another field to the user's and call it there_job 1 for user and 2 for admin in the admin part off the website update there_job that easy. see all the user select * from users where there_job='1' see all the admin select * from users where there_job='2' see all the user and admin select * from users where there_job='1' AND there_job='2' show current users there job select * from users where id='$id' while (job ..............){ $your_job=$job['there_job']; } echo" ".your $job['name']." $your_job"; Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722423 Share on other sites More sharing options...
contra10 Posted December 23, 2008 Author Share Posted December 23, 2008 hmmm..is there another way though? Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722426 Share on other sites More sharing options...
MadTechie Posted December 23, 2008 Share Posted December 23, 2008 Why do you all do it so hard. just add a another field to the user's and call it there_job 1 for user and 2 for admin in the admin part off the website update there_job that easy. I did also say that If you only want 1 group per used then just add an extra field in the users table to hold the Group ID then alter your SQL statment like so current SELECT * FROM Users Where ID = $UserID SELECT Users.*, Groups.Name FROM Users JOIN Groups ON Groups.id = Users.GroupID Where Users.ID = $UserID assuming the added to users field was called GroupID Hope that helps EDIT: corrections .. but its probably still wrong.. ahh bed is calling Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722428 Share on other sites More sharing options...
redarrow Posted December 23, 2008 Share Posted December 23, 2008 while (job ..............){ $your_job=$job['there_job']; if($your_job==1){ $your_job="user"; }elseif($your_job==2) $your_job="admin"; } Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722431 Share on other sites More sharing options...
redarrow Posted December 23, 2008 Share Posted December 23, 2008 still say noob got the best job. Quote Link to comment https://forums.phpfreaks.com/topic/138108-solved-users-in-groups-and-echo-the-group-on-profile/#findComment-722432 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.