Created
July 10, 2017 19:59
-
-
Save abel-masila/db1771ff3c7f944af3da71ee3f078692 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="wrapper wrapper-content"> | |
| <?php | |
| if(isset($_GET['page'])){ | |
| $page = $_GET['page']; | |
| if($page== 1){ | |
| include("pages/mycars.php"); | |
| } else if($data['location'] == ''){ | |
| include('pages/additional_info.php'); | |
| }else{ | |
| //display reports | |
| } | |
| i | |
| ?> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //get all cars of the logged in user | |
| $id = $data['id']; //super global var | |
| $num_rec_per_page=3; | |
| if (isset($_GET["view"])) { $view = $_GET["view"]; } else { $view=1; }; | |
| $start_from = ($view-1) * $num_rec_per_page; | |
| $all_cars = mysqli_query($connection, "SELECT * FROM cars WHERE userid=$id LIMIT $start_from, $num_rec_per_page"); | |
| $count = mysqli_num_rows($all_cars); | |
| ?> | |
| <div class="row"> | |
| <div class="col-xs-12 col-sm-12"> | |
| <nav class="services-pagination"> | |
| <ul class="pagination"> | |
| <?php | |
| $result = mysqli_query($connection, "SELECT * FROM cars WHERE userid=$id"); | |
| $total_records = mysqli_num_rows($result); | |
| $total_pages = ceil($total_records / $num_rec_per_page); | |
| ?> | |
| <li class=""> | |
| <a href="?page=1">First Page</a> | |
| </li> | |
| <?php | |
| for ($i=1; $i<=$total_pages; $i++) { | |
| ?> | |
| <li class=""> | |
| <?php | |
| echo "<a href='?page=1?view=".$i."'>".$i."</a> "; | |
| }; | |
| ?> | |
| </li> | |
| <?php | |
| ?> | |
| <li class=""> | |
| <a href="?page=1&view=<?php echo $total_pages?>">Last Page</a> | |
| </li> | |
| </ul> | |
| </nav> | |
| </div> | |
| </div> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome @sunriax. Actually that code is not working. I can't get pagination to work in this case