Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <footer>
- <?php
- // connect to database
- $con = mysqli_connect('localhost', 'root', '');
- mysqli_select_db($con, 'bobashop');
- // define how many results you want per page
- $results_per_page = 8;
- // find out the number of results stored in database
- //DONT NEED THIS AS WE USING THE PRODUCTS ONE INSTEAD
- // $sql = 'SELECT * FROM tblProducts';
- // $result = mysqli_query($con, $sql);
- $number_of_results = count($products);
- // determine number of total pages available
- $number_of_pages = ceil($number_of_results / $results_per_page);
- // determine which page number visitor is currently on
- if (!isset($_GET['page'])) {
- $page = 1;
- } else {
- $page = $_GET['page'];
- }
- // determine the sql LIMIT starting number for the results on the displaying page
- $this_page_first_result = ($page - 1) * $results_per_page;
- // retrieve selected results from database and display them on page
- $sql = "SELECT * FROM tblProducts LIMIT "
- . $this_page_first_result . ',' . $results_per_page;
- $result = mysqli_query($con, $sql);
- while ($row = mysqli_fetch_array($result)) {
- unset($rows);
- ?>
- <li>
- <a href="?action=view_product&product_id=<?php echo $row['PKProductID']; ?>">
- <?php echo $row['ProductName']; ?>
- </a>
- </li>
- <?php
- }
- // display the links to the pages
- for ($page = 1; $page <= $number_of_pages; $page++) {
- echo '<a href="index.php?page=' . $page . '">' . $page . '</a> ';
- }
- ?>
- </footer>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement