Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. error_reporting(E_ALL & ~E_NOTICE); //Hide php notifications on the page
  5. require_once "php/db.php";
  6. $db = db::get();
  7.  
  8. require_once "paginator.php";
  9.  
  10. $currentPage = $_GET["page"];
  11. $currentPage = (int)$currentPage;
  12. $selectfoods2 = "SELECT * FROM foods WHERE class = 'webshop' OR class = 'both'";
  13. $numberOfRows = $db->numrows($selectfoods2);
  14.  
  15. $selectusername = "SELECT `role_id` FROM `users` WHERE username ='".$_SESSION["username"]."'";
  16. $getuserdata = $db->getArray($selectusername);
  17.  
  18. if (count($getuserdata) > 0)
  19. {
  20. foreach ($getuserdata as $user)
  21. {
  22. $roleid = (int)$user["role_id"];
  23. }
  24. }
  25.  
  26. $pg = new Paginator($numberOfRows, $currentPage);
  27. if ($currentPage < 2) {
  28. $pg->from = 0;
  29. }
  30. else
  31. {
  32. $pg->from = ($currentPage - 1) * $pg->step;
  33. }
  34.  
  35. $foods = $db->getArray($selectfoods2." LIMIT ".$pg->from.", ".$pg->step);
  36.  
  37. ?>
  38.  
  39. <div class="row menu">
  40. <div class="col-md-10 col-md-offset-1 col-sm-9 col-sm-offset-2 col-xs-12">
  41.  
  42. <?php foreach ($foods as $food): ?>
  43.  
  44. <div class="container col-md-6" style="width: 50%;">
  45. <div class="jumbotron" style="border-radius: 15px; background-color: #8BC34A;">
  46. <img src="images/featured/<?php echo $food['imgpath']; ?>" style="border-radius: 50%;" align="left" height="100vh" width="100wv" alt="">
  47. <h3 class="webshop" onclick="window.location.href='php/foodform.php?foodid=<?php echo $food["id"]; ?>'"><?php echo $food['name']; ?></h3>
  48. <label for="" style="margin-left: 25%;" class="text-center"><?php echo $food["price"]." HUF"; ?></label>
  49. <?php if($_SESSION["username"] == "admin"): ?>
  50. <input type="button" class="btn btn-danger" name="removeWebshop" style="margin-left: 10%;" onclick="window.location.href='php/delete.php?foodid=<?php echo $food['id'];?>'" value="Remove"><br>
  51. <?php endif; ?>
  52.  
  53. <?php if(isset($_SESSION["username"]) && $roleid == 2) : ?>
  54. <form action="php/addtocart.php?item=<?php echo $food["id"]; ?>" method="post">
  55. <input type="submit" class="btn btn-success" value="Add to Cart">
  56. <input type="number" min="1" max="99" name="foodQuantity" value="1">
  57. </form>
  58. <?php endif; ?>
  59.  
  60. <?php if(!(isset($_SESSION["username"]))): ?>
  61. <input type="button" class="btn btn-primary" style="margin-left: 10%;" onclick="window.location.href='register.php'" value="Login for Shopping"><br>
  62. <?php endif; ?>
  63. </div>
  64. </div>
  65.  
  66. <?php endforeach; ?>
  67. </div>
  68. </div>
  69.  
  70. <div id="moreMenuContent"></div>
  71. <div class="text-center">
  72. <?php echo $pg->getPaginator(); ?>
  73. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement