Pagination Stopped [Resolved]
Posted: Sat Oct 12, 2013 3:28 am
Hey all,
In the middle of switching to mysqli, my pagination stopped working on the market. I don't see any reason why it shouldn't work. Any help would be great.
Code:
Everything works fine. I can post to the market and buy from the market. The pagination just stopped and wont' show the pages 
In the middle of switching to mysqli, my pagination stopped working on the market. I don't see any reason why it shouldn't work. Any help would be great.
Code:
Code: Select all
<?php
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 5;
$counter = 0;
$sql = "SELECT * FROM market ORDER BY amount DESC LIMIT $start_from, 5";
$user_query = mysqli_query($db_conx, $sql);
?>
<div>
<div align="center" class="float-left">Name</div>
<div align="center" class="float-center">Amount</div>
<div align="center" class="float-right">Price</div>
</div>
<br><br>
<?php
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
?>
<form action="market.php" method="post">
<div>
<div align="left" class="left"><?php echo $row["name"]; ?></div>
<div align="center" class="center"><?php echo number_format($row["amount"]); ?></div>
<div align="center" class="right"><?php echo number_format($row["price"]); ?></div>
<input type="hidden" id="hidden" name="hidden" value="<?php echo $row["mid"]; ?>">
<div align="center"><?php echo "<A href='market.php?mid=$row[mid]'?><font color='red'>Purchase" ?>;</a></font></div>
</div>
</form>
<?php
$counter = 1;
}
if ($counter == 0)
{
echo '<span id="errormess"><big><font color="red"><b>There are currently no sellers at this time!</b></font></big></span>';
}
?>
<?php
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 5;
$sql = "SELECT COUNT(name) FROM market";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
$total_records = $row[0];
$total_pages = ceil($total_records / 5);
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='market.php?page=".$i."'>".$i."</a> ";
};
?>