Created
August 7, 2020 07:30
-
-
Save Khant-Nyar/c6e523b5f86faf57a3d2158e176e78d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pagination | |
echo "<div class='w3-bar w3-center'>"; | |
if ($page > 1) { | |
echo "<a href='?page=1' class='w3-btn'><<</a>"; | |
$prevpage = $page - 1; | |
echo "<a href='?page=$prevpage' class='w3-btn'><</a>"; | |
} | |
$range = 3; | |
for ($i = ($page - $range); $i < ($page + $range) + 1; $i++) { | |
if (($i > 0) && ($i <= $totalpages)) { | |
if ($i == $page) { | |
echo "<div class='w3-btn w3-teal w3-hover-green'> $i</div>"; | |
} else { | |
echo "<a href='?page=$i' class='w3-btn w3-border'>$i</a>"; | |
} | |
} | |
} | |
if ($page != $totalpages) { | |
$nextpage = $page + 1; | |
echo "<a href='?page=$nextpage' class='w3-btn'>></a>"; | |
echo "<a href='?page=$totalpages' class='w3-btn'>>></a>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment