PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
New to the forum and with a problem. Articles on my site are divided in max 3 pages. If I have more than one page, I would like next and previous links (next on the bottom and previous on the top of the article). Here is what I came up with. It works but I would like to know if there is a better way.
<?
$next = '';
if (!isset($_GET['page'])) // This conditional was the same in both pagecount settings, so do it first. {
$next = '<a href="index.php?action=article&aid='.$_GET['aid'].'&page=1">Next</a>';
$prev = "";
} else {
$prev = '<a href="index.php?action=article&aid='.$_GET['aid'].'">Previous</a>';
if ($pageCount == 3 && $_GET['page'] == "2") {
$prev = '<a href="index.php?action=article&aid='.$_GET['aid'].'&page=1">Previous</a>';
}
}
if ($pageCount == 3 && $_GET['page'] == 1) // This conditional was a unique combination, so do it seperately {
$next = '<a href="index.php?action=article&aid='.$_GET['aid'].'&page=2">Next</a>';
}
}