Advertisement
Guest User

Untitled

a guest
Jan 25th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>Main Page</title>
  5.     <meta charset="utf-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">
  7.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  8.     <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
  9.     <link rel="stylesheet" type="text/css" href="main_page_style.css">
  10.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  11.     <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  12.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
  13. </head>
  14.  
  15. <script>
  16.     function adapt() {
  17.         if ($(window).width() <= 360){
  18.             $(".nav-btn").removeClass("fa-2x")
  19.             $(".nav-btn").addClass("fa-1x")
  20.         } else {
  21.             $(".nav-btn").removeClass("fa-1x")
  22.             $(".nav-btn").addClass("fa-2x")
  23.         }
  24.         if ($(window).width() <= 768){
  25.             $("#search-2").hide();
  26.             $(".search").show();
  27.         } else {
  28.             $("#search-2").show();
  29.             $(".search").hide();
  30.            
  31.         }
  32.     }
  33.  
  34.     $(document).ready(function f() {
  35.         adapt();
  36.         $("#search-1").hide();
  37.  
  38.         var menuHidden = true;
  39.  
  40.         $("#search").click(function f() {
  41.             if(menuHidden) {
  42.                 $("#search-1").slideDown();
  43.             } else {
  44.                 $("#search-1").slideUp();
  45.             }
  46.             menuHidden = !menuHidden;
  47.         });
  48.  
  49.         $(".search-bar").on("keyup", function() {
  50.             var value = $(this).val().toLowerCase();
  51.             $(".res").filter(function() {
  52.                 $(this).toggle($(this).children().children(".res-name").text().toLowerCase().indexOf(value) > -1);          
  53.             })
  54.         });
  55.  
  56.         $(".nav-link").click(function() {
  57.             var resType = $(this).text();
  58.             console.log(resType);
  59.             $(".res").filter(function() {
  60.                 $(this).toggle($(this).attr('name') === resType);          
  61.             })
  62.             $("#search-1").slideUp();
  63.             menuHidden = !menuHidden;
  64.         })
  65.  
  66.         $(".dropdown-item").click(function() {
  67.             var resType = $(this).text();
  68.             console.log(resType);
  69.             $(".res").filter(function() {
  70.                 $(this).toggle($(this).attr('name') === resType);          
  71.             })
  72.             $("#search-1").slideUp();
  73.             menuHidden = !menuHidden;
  74.         })
  75.  
  76.         $(".tutti").click(function () {
  77.             $(".res").toggle(true);
  78.             $("#search-1").slideUp();
  79.             menuHidden = !menuHidden;
  80.         })
  81.  
  82.         $( window ).resize(function() {
  83.             adapt();
  84.         })
  85.              
  86.     })
  87. </script>
  88.  
  89. <?php
  90.     include_once 'includes/db_connect.php';
  91.     include_once 'includes/functions.php';
  92.  
  93.     sec_session_start();
  94.     $logged = login_check($mysqli);
  95.     $servername = "localhost";
  96.     $username = "root";
  97.     $password = "";
  98.     $dbname = "project";
  99.  
  100.     $query = "select ragione_sociale, path_immagine_copertina, partita_iva, categoria
  101.                from ristoranti";
  102.  
  103.     $conn = new mysqli($servername, $username, $password, $dbname);
  104.     if($conn->connect_error){
  105.         echo "ERROR";
  106.     }
  107.  
  108.  
  109.  
  110.     $res = $conn->query($query);
  111. ?>
  112.  
  113. <body>
  114.     <header class="py-2 bg-dark">
  115.         <div class="container-fluid">
  116.             <div class="row flex-nowrap justify-content-between align-items-center">
  117.                 <div class="col-4">
  118.                     <a id="slide" class="text-muted" href="#">
  119.                         <i class="fas fas fa-angle-right nav-btn slide"></i>
  120.                         <?php
  121.                             if($logged){
  122.                                 ?>
  123.                                 <a href="#"><button class="btn btn-danger login account" type="submit" style="margin-right: 20px;">Notifiche</button></a>
  124.                                 <a href="#"><button class="btn btn-secondary account" type="submit">Ordini</button></a>
  125.                                 <?php
  126.                             }
  127.                         ?>
  128.                     </a>
  129.                 </div>
  130.                 <div class="col-4 text-center">
  131.                     <a href="#"><img id="logo" src="logo.png" alt="" width="30" height="30"></a>
  132.                 </div>
  133.                 <div class="col-4 d-flex justify-content-end align-items-center">
  134.                     <a id="search" class="text-muted nav-btn" href="#">
  135.                         <i class="fas fa-search search"></i>
  136.                         <?php
  137.                             if($logged){
  138.                                 ?>
  139.                                 <a href="#"><button class="btn btn-primary login account" type="submit" style="margin-right: 20px;">Account</button></a>
  140.                                 <a href="#"><button class="btn btn-danger account" type="submit">Esci</button></a>
  141.                                 <?php
  142.                             } else {
  143.                                 ?>
  144.                                 <a href="#"><button class="btn btn-success login account" type="submit" style="margin-right: 20px;">Login</button></a>
  145.                                 <a href="#"><button class="btn btn-secondary account" type="submit">Sign in</button></a>
  146.                                 <?php
  147.                             }
  148.                         ?>
  149.                     </a>
  150.                 </div>
  151.             </div>
  152.         </div>
  153.     </header>
  154.    
  155.     <div class="container" id="main">
  156.  
  157.         <div id="search-1">
  158.             <div class="input-group mb-3">
  159.                 <input id="search-bar" type="text" class="form-control search-bar" placeholder="Cerca per nome...">
  160.             </div>
  161.             <nav class="navbar navbar-expand-lg justify-content-center rounded border">
  162.                 <ul class="navbar-nav">
  163.                     <li class="nav-item">
  164.                         <a class="nav-link" href="#">Pizzeria</a>
  165.                     </li>
  166.                     <li class="nav-item">
  167.                         <a class="nav-link" href="#">Piadineria</a>
  168.                     </li>
  169.                     <li class="nav-item">
  170.                         <a class="nav-link" href="#">Fast food</a>
  171.                     </li>
  172.                     <li class="nav-item">
  173.                         <a class="nav-link" href="#">Romagnolo</a>
  174.                     </li>
  175.                     <li class="nav-item">
  176.                         <a class="nav-link" href="#">Vegano</a>
  177.                     </li>
  178.                     <li class="nav-item">
  179.                         <a class="nav-link" href="#">Etnico</a>
  180.                     </li>
  181.                     <li class="nav-item">
  182.                         <a class="nav-link" href="#">Italiano</a>
  183.                     </li>
  184.                     <li class="nav-item">
  185.                         <a class="nav-link" href="#">Gourmet</a>
  186.                     </li>
  187.                     <li class="nav-item">
  188.                         <a class="nav-link" href="#">Altro</a>
  189.                     </li>
  190.                     <li class="nav-item tutti">
  191.                         <a class="nav-link" href="#">Tutti</a>
  192.                     </li>
  193.                 </ul>
  194.             </nav>
  195.         </div>
  196.  
  197.         <div id="search-2" class="input-group mt-3 mb-3">
  198.             <div class="input-group-prepend">
  199.                 <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
  200.                     Categorie
  201.                 </button>
  202.                 <div class="dropdown-menu">
  203.                     <a class="dropdown-item" href="#">Pizzeria</a>
  204.                     <a class="dropdown-item" href="#">Piadineria</a>
  205.                     <a class="dropdown-item" href="#">Fast food</a>
  206.                     <a class="dropdown-item" href="#">Romagnolo</a>
  207.                     <a class="dropdown-item" href="#">Vegano</a>
  208.                     <a class="dropdown-item" href="#">Etnico</a>
  209.                     <a class="dropdown-item" href="#">Italiano</a>
  210.                     <a class="dropdown-item" href="#">Gourmet</a>
  211.                     <a class="dropdown-item" href="#">Altro</a>
  212.                     <a class="dropdown-item tutti" href="#">Tutti</a>
  213.                 </div>
  214.             </div>
  215.             <input id="search-input" type="text" class="form-control search-bar" placeholder="Cerca per nome...">
  216.         </div>
  217.  
  218.         <div class="flex-container">
  219.         <?php
  220.             while($row = mysqli_fetch_assoc($res)) {
  221.             ?>
  222.                 <div name="<?php echo $row["categoria"]; ?>" class="rounded bg-light res">
  223.                     <a href="restaurant_page.php?partita_iva=<?php echo $row["partita_iva"]; ?>">
  224.                     <div>
  225.                         <img class="rounded-top" src="<?php echo $row["path_immagine_copertina"]; ?>" alt="">
  226.                     </div>
  227.                     <div class="title font-weight-bold res-name">
  228.                         <?php
  229.                             echo $row["ragione_sociale"];
  230.                         ?>
  231.                     </div>
  232.                     </a>
  233.                 </div>
  234.             <?php
  235.             }
  236.             ?>
  237.         </div>
  238.     </div>
  239.     <footer>
  240.         <div class="footer-copyright text-center py-2 bg-dark" style="color: white;">
  241.             Tecnologie web 2018/2019 <br>
  242.             Credits: Filippo Pistocchi, Mattia Bonoli, Federico Cichetti.
  243.         </div>
  244.     </footer>
  245. </body>
  246. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement