Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>CubeMarket :: All Listings</title>
  5. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
  7. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  8. <style>
  9. h2, h4 {
  10. text-align: center;
  11. }
  12. </style>
  13. <?php
  14. require ("navbar.php");
  15. echo getNavBar("reports");
  16. ?>
  17. </head>
  18. <body>
  19. <div class="jumbotron text-center">
  20. <h1>All Cubes</h1>
  21. <p>Viewing All Listings</p>
  22. </div>
  23. <div class="container">
  24. <div id="recent-reports">
  25.  
  26. <table class="table table-striped">
  27.  
  28. <tr>
  29. <th>Name</th>
  30. <th>Description</th>
  31. <th>Category</th>
  32. <th>Condition</th>
  33. <th>Imgur Link</th>
  34. </tr>
  35.  
  36. <?php
  37. global $servername, $username, $password, $dbname, $lastPageButton, $nextPageButton;
  38.  
  39. $servername = "localhost";
  40. $username = "root";
  41. $password = "xxxxxx";
  42. $dbname = "cubemarket";
  43. error_reporting(0);
  44. $link = mysqli_connect($servername, $username, $password, $dbname, 3306) or die("Error on database connection.");
  45.  
  46. $lastPageButton = TRUE;
  47. $nextPageButton = TRUE;
  48.  
  49. if (!isset(((int)$_GET['p']))) {
  50. $results = mysqli_query($link, "SELECT * FROM `listings` ORDER BY id DESC LIMIT 20;") or die("Error on database query.");
  51. } else {
  52. $page = mysqli_real_escape_string($link, ((int)$_GET['p']));
  53. if ($page < 1) {
  54. $page = 1;
  55. }
  56. $first = (20 * ($page - 1)) + 1;
  57. $last = $first + 19;
  58. echo $first . " - " . $last;
  59. $results = mysqli_query($link, "SELECT * FROM `listings` WHERE id BETWEEN $first AND $last ORDER BY id DESC;") or die("Error on database query.");
  60. }
  61. if (mysqli_num_rows($results) > 0) {
  62. $tableResults = array();
  63. while ($row = mysqli_fetch_array($results)) {
  64. $id = $row['id'];
  65. $name = $row['name'];
  66. $description = $row['description'];
  67. $category = $row['category'];
  68. $condition = $row['cubecondition'];
  69. $imgurlink = $row['imgurlink'];
  70. $other = $row['otherinfo'];
  71. array_push($tableResults, array($id, $name, $description, $category, $condition, $imgurlink));
  72. }
  73.  
  74. $allRows = mysqli_query($link, "SELECT * FROM `listings`;") or die("Error on database query.");
  75.  
  76. if (!isset($_GET['p'])) {
  77. $lastPageButton = FALSE;
  78. } elseif (mysqli_num_rows($allRows) == (20 + 20 * mysqli_real_escape_string($link, ((int)$_GET['p'])))) {
  79. $nextPageButton = FALSE;
  80. }
  81.  
  82. foreach ($tableResults as $item) {
  83. echo "<tr><td><a href='http://192.99.70.9/listing.php?id='".$item[0].">$item[1]</a></td><td>$item[2]</td><td>$item[3]</td><td>$item[4]</td><td>$item[5]</td></tr>";
  84. }
  85. } else {
  86. echo "<tr><td>No listings</td><td>No listings</td><td>No listings</td><td>No listings</td><td>No listings</td></tr>";
  87. }
  88. ?>
  89.  
  90. </table>
  91.  
  92. <?php
  93. if ($lastPageButton) {
  94. $page = ((int)$_GET['p'])-1;
  95. echo "<a href='/cubes.php?p=".$page."'><button type='submit'>Last page</button></a>";
  96. }
  97.  
  98. if ($nextPageButton) {
  99. $page = ((int)$_GET['p'])+1;
  100. echo "<a href='/cubes.php/?p=".$page."'><button type='submit'>Next page</button></a>";
  101. }
  102. ?>
  103. </div>
  104. </div>
  105. </body>
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement