I have been scratching my head with this one for a couple hours now. Heres my problem;
i have two databases;
1) Categories
2) Roles
within ROLES i have;
ADMIN(id:1), BLOG(id:2), CMS(id:3)
in CATEGORIES i have;
SECTION1, SECTION2, SECTION3
each CATEGORIE has different roles attached, for example;
SECTION1 can be viewed by ADMIN and CMS - 1,3
SECTION2 can be viewed by ADMIN and BLOG - 1,2
SECTION3 can be viewed by ALL - 1,2,3
I have been trying to show these roles in a checkbox format, for editing purposes.
However im not quite getting it right :(
PHP Code:
$roles_q = mysql_query("SELECT * FROM `roles` ORDER BY `id`");
while($role = mysql_fetch_array($roles_q)) {
## THESE ARE COMMA DELIMIED, LIKE SHOWN ABOVE IN EXAMPLES
$roles = explode(',',$cat['roles']);
## EXPLODE THE ROLE ID (?)
$role_role = explode(',',$role['id']); // THESE ARNT EVEN COMMA DELIMINATED, IT JUST DIDNT LIKE $cat['roles'] ON ITS OWN
## NOW TO TRY MATCH THE CURRENT $cat['roles'] WITH THE $role['id']'S IN THE DATABASE
foreach($roles as $theroles) {
if(in_array($theroles, $role_role)) {
$found[] = $role['id'];
} }
So we should end up with a list of ROLES that are in that categorie;
Code:
<p><input type="checkbox" id="role[]" name="role[]" value="<?php echo $role['id']; ?>" class="checkbox" <?php if($role['id'] == $role['id']) { echo 'checked="checked"'; } ?> /> <?php echo $role['name']; ?></p>
Think of this as a forum, where admins and mods can see some forums, but members cant see them. Its just like that what im trying to achive, but i havent done the front end part yet, this is just to allow me to change the permissions in the back end.
Any help would be appreciated.