Hello I am trying to create some simple pagination, but my php skills are limited. I have var which is numOfPages and depending on how many pages there are I want to echo out 1 2 3 4 5 6 8 9 10. The numOfPages is dynamic and won’t always be 10. Each of these would be link to another page. My rough non working code is below. Hopefully you understand what I’m trying to do. I guess I need to create an array with the numbers in and loop over that with foreach?
Thanks in advance.
$pageNo = 1;
$numOfPages = 10;
foreach ($numOfPages) {
echo "<a href=\"link.php?page=" . $pageNo . "\>" . $pageNo . "</a> \n";
$pageNo++;
}
You should have: