csteff24 Posted January 12, 2010 Share Posted January 12, 2010 Right now I have a database that has a user field and a field for the ID of the club that they are advisor of The problem is that some people advise multiple clubs Right now I have them listed as seperate usernames For example: Username - ID - Password - Club John_Doe - 24 - password - 32 John_Does - 87 - password - 16 However, this causes problems when they log in - it turns into an infinite loop of some sort since there's two different users created with this same username Also, I have the name of their club show up using the Club ID, but if they have two clubs, how can I make both show up? Thank you! Let me know if this doesn't make sense... Quote Link to comment https://forums.phpfreaks.com/topic/188141-taking-multiple-values-into-consideration/ Share on other sites More sharing options...
crabfinger Posted January 12, 2010 Share Posted January 12, 2010 use implode and explode for the club so do something like this Username - ID - Password - Club John_Doe - 24 - password - 32|34|36|38 then explode('|',$clubs); Quote Link to comment https://forums.phpfreaks.com/topic/188141-taking-multiple-values-into-consideration/#findComment-993289 Share on other sites More sharing options...
ignace Posted January 12, 2010 Share Posted January 12, 2010 You need a many-to-many table: CREATE TABLE clubs_has_users ( users_id .., clubs_id .., PRIMARY KEY (users_id, clubs_id) ); If you could provide us with your database table structure then we may be of further assistance as to what should come on the .. Quote Link to comment https://forums.phpfreaks.com/topic/188141-taking-multiple-values-into-consideration/#findComment-993592 Share on other sites More sharing options...
csteff24 Posted January 12, 2010 Author Share Posted January 12, 2010 Thank you! I'm not familiar with either of those methods, so sorry if I'm not making sense! CREATE TABLE `members` ( `id` int(4) NOT NULL auto_increment, `username` varchar(65) NOT NULL default '', `password` varchar(65) NOT NULL default '', `club` int(3) NOT NULL, `perm` tinyint(1) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=412 ; So in order to add the | to users with multiple clubs, do I have to go through manually, or can I do it an easier way? Quote Link to comment https://forums.phpfreaks.com/topic/188141-taking-multiple-values-into-consideration/#findComment-993624 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.