Mysql database display

I have setup a MySQL database with user access levels. I have them display information from the different sections. I would like them to display info pertaining to their particular sections only. If say someone is with section 1 to only see section 1 info and not all sections. How do I achieve this? The access levels are working fine.

You could have a table with two fields:

section_id and group_id

Each record would record a section that the group is allowed to view. When a user requests a given page, you first look up which groups that user is a member of, then you look up if that group is allowed to to that section. If they are the section is displayed, if they aren’t then they get taken back to what page they were on, an error message is displayed and you might log the fact they tried to access a section they’re not allowed to access.

Thanks for your response. I have about 10 Groups number 1 - 10. Then each Group has numbered Sections 1 - 15. Meaning that each Group has say a section 1 … So, I am wondering how I can set these access to group/sections with your approach.

Can someone be a member of more then one group?

Can a group ever be allowed access to more then one section?

No. One can only be a member of one group as the group leader. Under him are sections. He can see only the sections under him. Each section has a section leader who can only see his section.I am using numeric values for both groups and sections. Groups are 1 - 10 and sections are more than 10. This means that each group has a say section 1, 2 ,3 etc.

Possible Tables:

  • User: Records details of the users
  • UserGroup: Lookup table for recording each group a user is a member of (allows for the future possibility of a user being a member of multiple groups)
  • Group: Records details of each group (possibly user ID as a FK from the users table)
  • GroupSection: Lookup table as to what sections a group can access (allows for the future possibility of a group being able to access multiple sections)
  • Section: Records details of each section

What’s the existing table structure (the output of a SHOW CREATE TABLE for each table)?

Could you please post some sample data for each table?

mid varchar(7)
password varchar(8)
role enum(pastor, rleader, zleader, cleader)
level int(11)
membership_tbl - has so many field but the only common one is mid (member ID)

I have a Registration form where these leaders register. Then as admin I assign the level from the database. I am using this level to assign what they have access to. But my challenge is when it comes to viewing records. It displays records from all regions (zones, sections). But what I want to achieve is that a region, zone, section leader can only see there particular region, zone, section respectively.

Currently I only have 2 tables. The Usertbl this captures user registration for login purposes and I also set there privileges in here. Then the membership tbl is basically used by these users to capture their region, zone, section members. At this point it works fine. There is about 4 levels of access. What I want to achieve is one a member from say central region logins in and goes to this membership table, he should only see members from his region, zone, sec.