#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2015
    Location
    Philippines
    Posts
    82
    Rep Power
    4

    User Rights to access menu


    Hello, I am currently developing a usersystem where everyone has limited access to each menu. For example: Administrator has access to 1,2,3,4 menu, while Moderator only to 1,2,3 and user to 1,2

    Table Menu:
    id | name |
    1 users
    2 settings
    3 moderator
    4 administrator

    Table User:
    id | user | useraccess | lastlogin
    1 Admin 1,2,3,4 929193
    2 User 1,2 929193
    3 Mod 1,2,3 929382

    How can I read the useraccess column in php? Or is there any better way to implement this. Thank you in advance!
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,884
    Rep Power
    9646
    Thank you for asking if there's a better way. Because there is.

    Instead of putting all the values into one column, use another table. Your user table is the id, user, and lastlogin. Then you add another table that has the user ID and the menu ID, with one row for each pairing: 1-1, 1-2, 1-3, 1-4, 2-1, 2-2, 3-1, 3-2, and 3-3. Ten rows.

    * Nine rows. I can't do math.

    Comments on this post

    • MonP agrees
    Last edited by requinix; August 17th, 2018 at 08:51 AM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2015
    Location
    Philippines
    Posts
    82
    Rep Power
    4
    Originally Posted by requinix
    Thank you for asking if there's a better way. Because there is.

    Instead of putting all the values into one column, use another table. Your user table is the id, user, and lastlogin. Then you add another table that has the user ID and the menu ID, with one row for each pairing: 1-1, 1-2, 1-3, 1-4, 2-1, 2-2, 3-1, 3-2, and 3-3. Ten rows.
    Good day!

    Thank you for answering my question. Now I get it! It is more easier to track each menu role using this.

IMN logo majestic logo threadwatch logo seochat tools logo