Solved

Need help with merging or joining to get values

Posted on 2012-03-16
1
258 Views
Last Modified: 2012-03-24
Hey,

Here's what I'm doing, I'm assigning users of my site permissions to admin certain pages on a user by user basis.  The way I'm doing it is by page id numbers.  For instance, to approve new members, the page number is "20".  In my user table, I implode all the page numbers that the user can admin and put them in to a field called "permissions_allowed".  So if joe blow can admin the approval section and the renewal sections, his permissions are 20#44.

I have another table that contains all of my pages on the site.  

When I display what users have what admin rights, instead of it showing as:

joe blow = 20#44

I would like it to show as

joe blow = Member approvals, member renewals

I have already dumped the permissions in to an array and have no problem displaying the numbers, I just need the best way to match the numbers with the pages so I can display the pages.

Maybe a IF or Switch statement?  Would it be better to join the tables when I'm querying?  What do you all think?
0
Comment
Question by:deputycheek
1 Comment
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37732485
I think I would do it like this...

Table of Members
Table of Pages
Table of Members_Pages

The third table would contain two columns - the keys of the rows where members and pages intersect.  This is called a junction table, and it provides the relationship between members and pages.  It lets you answer questions like "What can Joe Blow change?" or "Who can change the Renewals?" or "Can Jane Doe change Approvals?"

If that part makes sense to you, then it is easy to write a query something like this

SELECT name, page FROM members, pages, members_pages WHERE members_pages.id = 3
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question