I am using GET method to display pagination for a page(home.php) that displays the results of a search done on a form(index.php). The problem is that I don't know how to direct to the next page. What I am currently doing does not direct at all.
index.php
<form action='home.php' action='get'>
//Form elements
</form>
home.php
if (isset($_GET['submit'])){
//Display search results
//Shows pagination
$page_count2 = "SELECT COUNT(id) FROM offers WHERE school = :school";
$rs_result = $db-> query($page_count2, array('school' => $_GET['school']));
$row = $rs_result->fetch();
$total_records = $row[0];
$total_pages = ceil($total_records / 6);
echo "
<div class='row text-center'>
<ul class='pagination pag'>";
for ($i=1; $i<=$total_pages; $i++) {
if ($page == $i)
echo "<li class='active' >";
else
echo "<li>";
echo "<a href='$_SERVER[REQUEST_URI]?page=$i' >$i</a></li>"; //This is my problem
};
echo "</ul></div>";
}
'Typo Error
echo '<a href="'.$_SERVER['REQUEST_URI'].'?page='.$i.'">'.$i.'</a></li>';