You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.9 KiB

  1. <?php
  2. session_start();
  3. header('Content-Type: text/html; charset=UTF-8');
  4. $db = include("config.php");
  5. ?>
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1">
  10. <title>FutureBuilding Shop</title>
  11. <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
  12. <script src="js/bootstrap.js"></script>
  13. <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  14. <link rel="stylesheet" type="text/css" href="css/style.css">
  15. </head>
  16. <body>
  17. <div id="myModal" class="modal bd-example-modal-sm" tabindex="-1" role="alert" aria-hidden="true">
  18. <div class="modal-dialog modal-md">
  19. <div class="modal-content">
  20. <div class="modal-header">Внимание!</div>
  21. <div class="modal-body"><span id="axaxa">Вы добавили товар в корзину.</span></div>
  22. </div>
  23. </div>
  24. </div>
  25. <nav class="navbar fixed-top navbar-light bg-light navbar-expand border">
  26. <a class="navbar-brand" href="index.php">FutureBuilding</a>
  27. <ul class="navbar-nav">
  28. <li class="nav-item dropdown">
  29. <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  30. Меню
  31. </a>
  32. <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
  33. <a class="nav-link" href="shop.php">Каталог товаров</a>
  34. <a class="nav-link" href="projects.php">Наши проекты</a>
  35. <a class="nav-link" href="brigade.php">Строительная бригада</a>
  36. </div>
  37. </li>
  38. <li class="nav-item">
  39. <a class="nav-link" href="cart.php">Корзина</a>
  40. </li>
  41. </ul>
  42. </nav>
  43. <div class="container">
  44. <input class="form-control" id="myInput" type="text" placeholder="Поиск..">
  45. <div id="itemlist">
  46. <?php
  47. $result = mysqli_query($db, "SELECT * FROM menu");
  48. while ($myrow = mysqli_fetch_array($result)) { ?>
  49. <div class="item-info col-12">
  50. <img width="200px" src="<?php echo $myrow['imageid'] ?>">
  51. <br>
  52. <span class="item-name"><?php echo $myrow['name'] ?></span> <br>
  53. <span class="item-cost"><?php echo $myrow['cost'] ?> ₸</span> <br>
  54. <input class="col-6" min="1" type="number" name="Количество" id="<?php echo $myrow['id'] ?>" value=1>
  55. <button onclick="myFunction(<?php echo $myrow['id'] ?>)" class="btn btn-primary add-to-cart col-4"></button>
  56. </div>
  57. <?php } ?>
  58. </div>
  59. </div>
  60. <footer class="page-footer font-small blue border">
  61. <div class="footer-copyright text-center py-3">
  62. ©FutureBuilding
  63. </div>
  64. </footer>
  65. <script>
  66. $(document).ready(function() {
  67. $("#myInput").on("keyup", function() {
  68. var value = $(this).val().toLowerCase();
  69. $("#itemlist div").filter(function() {
  70. $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
  71. });
  72. });
  73. });
  74. function myFunction(idid) {
  75. var x = document.getElementById(idid).value;
  76. if (x > 0) {
  77. jQuery(document).ready(function($) {
  78. $.ajax({
  79. type: 'GET',
  80. url: 'add.php',
  81. data: {
  82. itemid: idid,
  83. quan: x
  84. },
  85. success: function(res) {
  86. $('#myModal').modal('show')
  87. }
  88. });
  89. });
  90. } else {
  91. alert("Нужно положительное количество товаров!");
  92. }
  93. }
  94. function delitem(idid) {
  95. jQuery(document).ready(function($) {
  96. $.ajax({
  97. type: 'GET',
  98. url: 'delete.php',
  99. data: {
  100. action: "delete",
  101. del: idid
  102. },
  103. success: function(res) {
  104. location.reload();
  105. }
  106. });
  107. });
  108. }
  109. function destr() {
  110. jQuery(document).ready(function($) {
  111. $.ajax({
  112. type: 'GET',
  113. url: 'destroy.php',
  114. data: {},
  115. success: function(res) {
  116. location.reload();
  117. }
  118. });
  119. });
  120. }
  121. </script>
  122. </body>
  123. </html>