I am trying 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 the navigation link on the pagination code does not direct to the next page, it instead directs to an empty page (I believe the normal state of home.php
) even when the URL at the address reads home.php?page=2
.
index.php
<form action='home.php' action='post'>
//Form elements
</form>
home.php
if (isset($_POST['submit'])){
//Display search results
//Shows pagination
$page_count2 = "SELECT COUNT(id) FROM offers WHERE school = :school";
$rs_result = $db-> query($page_count2, array('school' => $_POST['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='home.php?page=$i' >$i</a></li>";
};
echo "</ul></div>";
}