Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>CubeMarket :: All Listings</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
- <style>
- h2, h4 {
- text-align: center;
- }
- </style>
- <?php
- require ("navbar.php");
- echo getNavBar("reports");
- ?>
- </head>
- <body>
- <div class="jumbotron text-center">
- <h1>All Cubes</h1>
- <p>Viewing All Listings</p>
- </div>
- <div class="container">
- <div id="recent-reports">
- <table class="table table-striped">
- <tr>
- <th>Name</th>
- <th>Description</th>
- <th>Category</th>
- <th>Condition</th>
- <th>Imgur Link</th>
- </tr>
- <?php
- global $servername, $username, $password, $dbname, $lastPageButton, $nextPageButton;
- $servername = "localhost";
- $username = "root";
- $password = "xxxxx";
- $dbname = "cubemarket";
- error_reporting(0);
- $link = mysqli_connect($servername, $username, $password, $dbname, 3306) or die("Error on database connection.");
- $lastPageButton = TRUE;
- $nextPageButton = TRUE;
- if (!isset($_GET['p'])) {
- $results = mysqli_query($link, "SELECT * FROM `listings` ORDER BY id DESC LIMIT 20;") or die("Error on database query.");
- } else {
- $page = mysqli_real_escape_string($link, $_GET['p']);
- if ($page < 1) {
- $page = 1;
- }
- $first = (20 * ($page - 1)) + 1;
- $last = $first + 19;
- echo $first . " - " . $last;
- $results = mysqli_query($link, "SELECT * FROM `listings` WHERE id BETWEEN $first AND $last ORDER BY id DESC;") or die("Error on database query.");
- }
- if (mysqli_num_rows($results) > 0) {
- $tableResults = array();
- while ($row = mysqli_fetch_array($results)) {
- $id = $row['id'];
- $name = $row['name'];
- $description = $row['description'];
- $category = $row['category'];
- $condition = $row['cubecondition'];
- $imgurlink = $row['imgurlink'];
- $other = $row['otherinfo'];
- array_push($tableResults, array($name, $description, $category, $condition, $imgurlink));
- }
- $allRows = mysqli_query($link, "SELECT * FROM `listings`;") or die("Error on database query.");
- if (!isset($_GET['p'])) {
- $lastPageButton = FALSE;
- } elseif (mysqli_num_rows($allRows) == (20 + 20 * mysqli_real_escape_string($link, $_GET['p']))) {
- $nextPageButton = FALSE;
- }
- foreach ($tableResults as $item) {
- echo "<tr><td><a href='http://xxx.xx.x.x/listing.php?id=$id'>$item[0]</a></td><td>$item[1]</td><td>$item[2]</td><td>$item[3]</td><td>$item[4]</td></tr>";
- }
- } else {
- echo "<tr><td>No listings</td><td>No listings</td><td>No listings</td><td>No listings</td><td>No listings</td></tr>";
- }
- ?>
- </table>
- <?php
- if ($lastPageButton) {
- echo "<form action='cube.php/?p={$_GET['p']-1}'><button type='submit'>Last page</button></form>";
- }
- if ($nextPageButton) {
- echo "<form action='cube.php/?p={$_GET['p']+1}'><button type='submit'>Next page</button></form>";
- }
- ?>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement