Andrew7v
-
Posts
4 -
Joined
-
Last visited
Posts posted by Andrew7v
-
-
Hello, I have a very basic SQL query, and i added some pagination code i found from a website cause i'm not good at that logic. It works fine but it doesn't have the code to highlight the current page link within the page numbers. So if on page 2 for example: 1 - [2] - 3 - 4 (page 2 would be highlighted (and non-hyper-linked).
Can anyone please help me add the additional code required to do this?
ThanksHere's the code...
<?PHP include("includes/myconnection.php"); $num_rec_per_page=1; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * $num_rec_per_page; $app="yes"; $sql = "SELECT * FROM listings WHERE approved='$app' order by auto_id desc LIMIT $start_from, $num_rec_per_page"; $rs_result = mysql_query ($sql); //run the query ?> <?php //The listing of results... while ($row = mysql_fetch_assoc($rs_result)) { ?> <tr> <td><?php echo $row['title']; ?><br /> <?php echo $row['descrip']; ?><br /><br /> </td> </tr> <?php }; ?> <?php //Bottom Pagination.... $sql = "SELECT * FROM listings"; $rs_result = mysql_query($sql); //run the query $total_records = mysql_num_rows($rs_result); //count number of records $total_pages = ceil($total_records / $num_rec_per_page); echo "<a href='pagination.php?page=1'>".'First'."</a> "; // Goto 1st page for ($i=1; $i<=$total_pages; $i++) { echo "<a href='pagination.php?page=".$i."'>".$i."</a> "; }; echo "<a href='pagination.php?page=$total_pages'>".'Last'."</a> "; // Goto last page ?>
Pagination Help please...
in PHP Coding Help
Posted
Ok, thanks for that. I'll work on it.