Advertisement
miguelgoncalves01

Pratos.php

Dec 13th, 2018
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1.    
  2.     <?php include 'header.php' ; ?>
  3.            
  4.         <div class="product-page small-11 large-12 columns no-padding small-centered">
  5.            
  6.             <div class="global-page-container">
  7.  
  8.                 <?php
  9.  
  10.                     $cod_prato = $_GET['prato'];
  11.                     $server = 'localhost';
  12.                     $user = 'root';
  13.                     $password = '';
  14.                     $db_name = 'restaurante';
  15.                     $port = '3306';
  16.  
  17.                     $db_connect = new mysqli($server,$user,$password,$db_name,$port);
  18.                     mysqli_set_charset($db_connect,"utf8");
  19.  
  20.                     if ($db_connect->connect_error) {
  21.                         echo 'Falha: ' . $db_connect->connect_error;
  22.                     } else {
  23.                         //echo 'Conexão feita com sucesso' . '<br><br>';
  24.                         $sql = " SELECT * from pratos WHERE codigo='$cod_prato'";
  25.                         $result = $db_connect->query($sql);
  26.  
  27.                         if($result->num_rows > 0) {
  28.  
  29.                             while ($row = $result->fetch_assoc()){
  30.                                 $prato_nome= $row['nome'];
  31.                                 $prato_categoria= $row['categoria'];
  32.                                 $prato_descr= $row['descricao'];
  33.                                 $prato_preco= $row['preco'];
  34.                                 $prato_calorias= $row['calorias'];
  35.                             }
  36.  
  37.  
  38.                         }
  39.                     }
  40.  
  41.                 ?>
  42.  
  43.                     <?php if ($prato_nome != NULL){ ?>
  44.  
  45.                
  46.                         <div class="product-section">
  47.                             <div class="product-info small-12 large-5 columns no-padding">
  48.                                 <h3><?php echo $prato_nome; ?></h3>
  49.                                 <h4><?php echo $prato_categoria; ?></h4>
  50.                                 <p><?php echo $prato_descr; ?>
  51.                                 </p>
  52.  
  53.                                 <h5><b>Preço: </b>R$ <?php echo $prato_preco; ?></h5>
  54.                                 <h5><b>Calorias: </b><?php echo $prato_calorias; ?></h5>
  55.                             </div>
  56.  
  57.                             <div class="product-picture small-12 large-7 columns no-padding">
  58.                                 <img src="img/cardapio/<?php echo $cod_prato; ?>.jpg" alt="Foto do prato: <?php echo $prato_nome; ?>">
  59.                             </div>
  60.  
  61.                         </div>
  62.  
  63.  
  64.               <?php } else {
  65.               echo 'Prato Não Encontrado' . ' <br>';
  66.                }  ?>
  67.  
  68.  
  69.                 <div class="go-back small-12 columns no-padding">
  70.                     <a href="cardapio.php"><< Voltar ao Cardápio</a>
  71.                 </div>
  72.  
  73.             </div>
  74.         </div>
  75.            
  76.  
  77.  
  78.            
  79.  
  80.         <?php include 'footer.php' ; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement