Basically I'm trying to limit what a logged in user can see depending on what their rank is. The content is several rows, all with different rank requirements. If the user doesn't have the required rank, he will not be able to view that row. However, my problem here is that if one row has a higher rank requirement than any rows below it and the user does not have that rank, all rows below will not be visible either.
public function Categories() {
global $Template, $CatArray;
$CatArray = array();
$PermissionTable = array();
$QueryCat = $this->mysqli->query("SELECT * FROM categories ORDER BY id ASC");
while($FetchCat = $QueryCat->fetch_array()) {
$PermissionTable["category"] = array("id" => $FetchCat["id"]); // store category ID as an id sub-array
$data = explode(",", $FetchCat["ranks"]); // the ranks row in the database contains all ranks that can see this category, so here we split them up.
foreach($data as $number) {
$PermissionTable["category"] += array(
"rank" => $data // apply rank requirements in a sub-array again
);
}
if(in_array($Template["user"]["user_group"], $PermissionTable["category"]["rank"])) { // here, if the users rank is in the rank sub-array, they will be able to see it
$CatArray[] = $FetchCat;
} else { // otherwise display nothing
$CatArray[] = null;
}
}
$Template["CatArray"] = $CatArray;
return $CatArray;
}
