Hey Everyone,
I've been trying to figure out in my head what the best way of having users in multiple groups is... but I'm not sure, so I'm looking for some advice.
I have a user management system. My DB has 2 tables, one for users and one for groups. The Users table has a lot of information in it, but the important pieces are USER_ID, USER_NAME and GROUP_ID. The group table only has GROUP_ID and GROUP_NAME.
On the website, specific pages are only accessible to logged in users who are members of specific groups. I'm basically using a hard-coded if statement to either allow or deny access to specific pages.
What I'm wanting to do, though, is to be able to put users in multiple groups. So, if I have 1 page which is hard-coded to allow Group 1 access, and another for Group 2... but I want some people to be able to access both -- I don't have to create Group 3 and add them to the hard-coded if statement. I can just put specific users in both Group 1 and 2.
I'm not sure how to best store the information, though. I was thinking of using serialize/unserialize and storing it that way in the "GROUP_ID" field of the user table... but that doesn't seem like a very elegant solution, and I was wondering if someone here might have thoughts as to a better way of doing this.