I am creating a page for someone where it will display all orders in the database, limited to 10 per page.
It works to that end, but now the issue is when I try to get a max number of pages using the below code:
$msql = "SELECT * FROM orders";
$mresult = $db->query($msql);
if(is_object($mresult) && $mresult->num_rows > 0)
{
if($mresult->num_rows > 10)
{
$maxpage = $mresult->num_rows / 10 + 1;
}
else
{
$maxpage = 1;
}
}
It won't set the $maxpage variable to anything other than 1 unless there are 20 or more orders in the database.
Right now, I have 11 test orders in the database, so when it divides by 10, it should set max pages to 1, + 1 additional page since there are more than 10 orders.
I have scoured the web looking for a solution, and have came up empty handed. Any thoughts or suggestions?
EDIT:
Added code at bottom of the table the actual orders are displayed for further troubleshooting:
<tr>
<td colspan="2" align="left"><a href="orders?start=<?php if($page == 1) { echo 0; } else { echo $start - 10; } ?>&page=<?php if($page == 1) { echo 1; } else { echo $page - 1; } ?>"><<<<</a> Prev</td>
<td align="center">Page <?php if(isset($_GET['page'])) { echo $_GET['page'] . ' of ' . $maxpage; } else { echo '1 of 1'; } ?></td>
<td colspan="2" align="right">Next <a href="orders?start=<?php if($page <= $maxpage) { echo 0; } else { echo $start + 10; } ?>&page=<?php if($page < $maxpage) { echo $page + 1; } else { echo $page; } ?>">>>>></a></td>
</tr>