Jump to content

Taking multiple values into consideration


csteff24

Recommended Posts

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...

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 ..

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.