jsschmitt Posted November 27, 2009 Share Posted November 27, 2009 I need some help here.. I have a users table, and I am looking to add these users to groups. I need some help figuring this out. I have no clue where to begin, can you point me in the right direction, or give me some help? Quote Link to comment https://forums.phpfreaks.com/topic/183099-help-users-with-groups/ Share on other sites More sharing options...
Zane Posted November 27, 2009 Share Posted November 27, 2009 Well your first step is done... having a list of your users in a users table. Your next step is to have a groups table....having a list of all of your groups. The last step (which is really a part of the first step) is to put a column within the users table to signify which group a particular user is in. You would use the group's primary key for the value. So. if in your groups table.. the 3rd group was "Da Bears" and in the users table you must have "Joe" in that group. You would give Joe's group column a value of 3.. Get it? it's like number matching Quote Link to comment https://forums.phpfreaks.com/topic/183099-help-users-with-groups/#findComment-966311 Share on other sites More sharing options...
jsschmitt Posted November 27, 2009 Author Share Posted November 27, 2009 Ok... So I follow you. I think. Groups: ID Group 1 Testers Users: ID Name Group 1 Josh 1 Now... how do I show that interaction between them? Quote Link to comment https://forums.phpfreaks.com/topic/183099-help-users-with-groups/#findComment-966316 Share on other sites More sharing options...
Zane Posted November 27, 2009 Share Posted November 27, 2009 exactly! Now... how do I show that interaction between them? SELECT name FROM users INNER JOIN groups ON users.group = group.id Quote Link to comment https://forums.phpfreaks.com/topic/183099-help-users-with-groups/#findComment-966324 Share on other sites More sharing options...
jsschmitt Posted November 28, 2009 Author Share Posted November 28, 2009 Gah... Still lost.. Ok... Here is what I have.. Families: ID Name 1 Schmitt Users: id username first_name last_name family password 1 jschmitt Schmitt Schmitt 1 xxxxxxxxx And the code I currently have.. <?php session_start(); $sesuser = $_POST['username']; $sespass = $_POST['password']; include 'php/includes/dbconnect.php'; $query = "SELECT `username` , `family` FROM `users` WHERE `username` = '".$sesuser."' AND `password` = '".$sespass."' INNER JOIN `group` ON users.family = families.id"; $result = mysql_query($query) or die('Error, query failed'); if(mysql_num_rows($result)){ $_SESSION['username'] = $sesuser; } while ($row = mysql_fetch_array($result)) { $_SESSION['family'] = $row['family']; } include 'php/includes/closedb.php'; zheader('Location: http://anomymage.com/famshare/') ?> Please... tell me what I am doing wrong! Quote Link to comment https://forums.phpfreaks.com/topic/183099-help-users-with-groups/#findComment-966749 Share on other sites More sharing options...
fenway Posted November 28, 2009 Share Posted November 28, 2009 Put the where clause after the join. Quote Link to comment https://forums.phpfreaks.com/topic/183099-help-users-with-groups/#findComment-967053 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.