Nerviie

GALERIA

May 14th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Galeria</title>
  5.     <style type="text/css">
  6.         #principal{
  7.             width: 650px;
  8.             margin: auto;
  9.         }
  10.         body{
  11.             font-family: Comic Sans ms;
  12.             background-color: #fbeec1;
  13.         }
  14.         #listagem{
  15.             border-color: black;
  16.             background-color: white;
  17.             color: black;
  18.             text-align: center;
  19.         }
  20.     </style>
  21. </head>
  22. <body>
  23.     <?php
  24.         $bd_host="localhost";
  25.         $bd_user="root";
  26.         $bd_password="";
  27.         $bd_database="gf";
  28.  
  29.         $ni=$tit=$desc=$idt=$data=$foto='';
  30.         $existe=false;
  31.  
  32.         $mysqli = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
  33.  
  34.         // Mostrar erros, caso existam
  35.         if ($mysqli->connect_error) {
  36.             die('Erro: ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
  37.         }
  38.         $msg="";
  39.     ?>
  40.     <h1>Galeria</h1>
  41.     <form action="" method="post" enctype="multipart/form-data" name="frmi">
  42.         <select name="listar" onchange="document.frmi.submit();" id="listagem">
  43.             <option value="-1">SELECCIONE O TIPO A LISTAR</option>
  44.             <?php
  45.                 $sqa="SELECT id_tipo,Tipo from tabela_tipo order by id_tipo";
  46.                 $statement = $mysqli->prepare($sqa);
  47.                 $statement->execute();
  48.                 $statement->bind_result($IDi,$tit);
  49.                 while($statement->fetch()) {
  50.                     echo '<option value="'.$IDi.'">'.$tit .'</option>';
  51.                 }  
  52.             ?>
  53.         </select>
  54.     </form>
  55.     <?php
  56.         if(isset($_POST["listar"]))
  57.         {
  58.             $qr = "SELECT foto from tabela_fotos where id_tipo=?";
  59.             $results = $mysqli->query($qr);
  60.             echo "<div id='principal'>";
  61.             echo "<table id='tabela1' style='margin:auto' >";
  62.             while ($row = $results->fetch_assoc()) {
  63.                 echo "<tr >";
  64.                 echo "<td >";
  65.                 ?>
  66.                 <img src="<?php echo $row['foto'];?>" width="200px">
  67.                 <?php
  68.                 echo "</td>";
  69.                 echo "<td >";
  70.                 if($row = $results->fetch_assoc()){
  71.                     ?>
  72.                     <img src="<?php echo $row['foto'];?>" width="200px">
  73.                     <?php
  74.                         echo "</td>";
  75.                 }
  76.                 echo "<td>";
  77.                 if($row = $results->fetch_assoc()){
  78.                     ?>
  79.                     <img src="<?php echo $row['foto'];?>" width="200px">
  80.                     <?php
  81.                     echo "</td>";
  82.                 }
  83.                 echo "</tr>";
  84.             }
  85.             echo "</table>";
  86.             echo "</div>";
  87.         }
  88.    
  89.     ?>
  90.     <?php
  91.         $mysqli->close();
  92.     ?>
  93. </body>
  94. </html>
Advertisement
Add Comment
Please, Sign In to add comment