Yes i have a CMS where pages can have user access based on what role
when I want to update a page
I go to the update page,
get my roles as a result from the roles table
loop
print them out in a checkobx
/loop
I tried to do a loop inside the roles loop, but it prints out the roles twice, but do the selected right
here is the code:
<?
$getRoles = $db->get_results("SELECT * FROM userroles ORDER BY role");
foreach ($getRoles as $getRoles) {
$getSelected = $db->get_results("SELECT pageid, prole FROM pageaccess WHERE pageid = ".$pages->pid."");
foreach ($getSelected as $getSelected) {
if ($getSelected->prole == $getRoles->urid) {
//check the boxes that is checked
echo "<input type=\"checkbox\" value=\"".$getRoles->urid."\" name=\"insertIntoPageAccess[]\" id=\"other\" onClick=\"JavaScript:uncheckAll();\" CHECKED> ".$getRoles->role." \n";
}
else {
echo "<input type=\"checkbox\" value=\"".$getRoles->urid."\" name=\"insertIntoPageAccess[]\" id=\"other\" onClick=\"JavaScript:uncheckAll();\"> ".$getRoles->role." \n";
}
}
}
?>
a bit object oriented here though.