I have a PHP file that loads three different pages: a user's followers, following, and their friends (represented below by a, b, and c). Each "page" has different privacy settings depending on who's viewing the website, so a, b, and c have true/false values. If the value is false, then that user cannot view the page. I want to create next and previous buttons, but in order to determine which page is next/previous, I need to factor in the user's privacy. For example, if the user only shows b, there would be no next/previous, but if they showed a, and c, then next/previous for a would be c, and for c it would be a. I wrote some code below that tries to accomplish this, but is there a simpler way to do this without being so repetitious? It's also important that it loop, so even if I'm on page c, the next button will bring me to page a.
$a = $_GET['a']; // true/false
$b = $_GET['b']; // true/false
$c = $_GET['c']; // true/false
$cur = // current page: a, b, or c
if($cur = $a) {
if($b) {
$next = $b;
}
else if($c) {
$next = $c;
}
else {
$next = $a;
}
if($c) {
$previous = $c;
}
else if($b) {
$previous = $b;
}
else {
$previous = $a;
}
}
if($cur = $b) {
if($c) {
$next = $c;
}
else if($a) {
$next = $a;
}
else {
$next = $b;
}
if($a) {
$previous = $a;
}
else if($c) {
$previous = $c;
}
else {
$previous = $b;
}
}
if($cur = $c) {
if($a) {
$next = $a;
}
else if($b) {
$next = $b;
}
else {
$next = $c;
}
if($b) {
$previous = $b;
}
else if($a) {
$previous = $a;
}
else {
$previous = $c;
}
}