Advertisement
EduzZiTo

Galeria

May 5th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pt" dir="ltr">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Galeria</title>
  6. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  7. <style media="screen">
  8. .titulo{
  9. text-align: center;
  10. }
  11. td:hover{
  12. background-color: blue;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <?php
  18. include"cabecalho.php";
  19. $bd_host="localhost";
  20. $bd_user="root";
  21. $bd_password="";
  22. $bd_database="galeria";
  23. $tipo="";
  24. $msg="";
  25. $erro=0;
  26. $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
  27.  
  28. $existe=false;
  29.  
  30. if ($ms->connect_error) {
  31. $msg= '<h3 class="erro">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
  32. $erro=1;
  33. }
  34.  
  35. ?>
  36. <?php
  37.  
  38. $qr = "SELECT imagem from tbl_fotos";
  39.  
  40. $results = $ms->query($qr);
  41. echo "<h1 class='titulo'>TODAS AS FOTOS</h1>";
  42. echo "<div id='ftt'>";
  43.  
  44.  
  45. echo "<table style='margin:auto' colspan='2'>";
  46. while ($row = $results->fetch_assoc()) {
  47. echo "<tr>";
  48. echo "<td>";
  49. ?>
  50. <img src="<?php echo $row['imagem'];?>" width="200px">
  51. <?php
  52. echo "</td>";
  53. echo "<td>";
  54. if($row = $results->fetch_assoc()){
  55.  
  56. ?>
  57. <img src="<?php echo $row['imagem'];?>" width="200px">
  58. <?php
  59. echo "</td>";
  60. }
  61. echo "<td>";
  62. if($row = $results->fetch_assoc()){
  63. ?>
  64. <img src="<?php echo $row['imagem'];?>" width="200px">
  65. <?php
  66. echo "</td>";
  67. }
  68. echo "</tr>";
  69. }
  70. echo "</table>";
  71. echo "</div>";
  72.  
  73. ?>
  74. <?php
  75. if (isset($_POST['pesq']))
  76. {
  77. $qr="SELECT tipo FROM tbl_tipo where tipo=?";
  78. $st=$ms->prepare($qr);
  79. $st->bind_param('s', $_POST["num"]);
  80. $st->execute();
  81. $st->bind_result($tipo);
  82. if($st->fetch())
  83.  
  84. $st->close();
  85.  
  86.  
  87.  
  88. $qro="SELECT imagem from tbl_fotos inner join tbl_tipo on tbl_fotos.tipo=tbl_tipo.tipo WHERE tbl_fotos.tipo='$tipo'";
  89.  
  90. $results = $ms->query($qro);
  91. echo "<div>";
  92. echo "<h1 class='titulo'>Fotos por tipo selecionado</h1>";
  93. echo "<table style='margin:auto'>";
  94. while ($row1 = $results->fetch_assoc()) {
  95. echo "<tr>";
  96. echo "<td>";
  97. ?>
  98. <img src="<?php echo $row1['imagem'];?>" width="200px">
  99. <?php
  100. echo "</td>";
  101.  
  102. echo "<td>";
  103. if($row1 = $results->fetch_assoc()){
  104. ?>
  105. <img src="<?php echo $row1['imagem'];?>" width="200px">
  106. <?php
  107. echo "</td>";
  108. }
  109. echo "<td>";
  110. if($row1 = $results->fetch_assoc()){
  111. ?>
  112. <img src="<?php echo $row['imagem'];?>" width="200px">
  113. <?php
  114. echo "</td>";
  115. }
  116. echo "</tr>";
  117. }
  118. echo "</table>";
  119. echo "</div>";
  120.  
  121.  
  122.  
  123.  
  124. }
  125.  
  126.  
  127. ?>
  128. <form class="" action="" method="post" name="tiposs">
  129. <input type="hidden" name="pesq" value="1">
  130. <br><br>
  131. <h4 style="text-align:center">Tipo<select name="num" onchange="muda()">
  132. <option value=""></option>
  133. <?php
  134. $qr="SELECT tipo FROM tbl_tipo";
  135. $st = $ms->query($qr);
  136. while($row = $st->fetch_assoc())
  137. {
  138. echo '<option value = "'.$row['tipo'].'">'.$row['tipo'].' </option>';
  139. }
  140. $st->close();
  141. ?>
  142. </select></h4>
  143. <br><br>
  144. </form>
  145. <?php include"rodape.php"; ?>
  146. <script>
  147. function muda(){
  148. document.tiposs.submit();
  149. document.getElementById("ftt").style.visibility="hidden";
  150. }
  151.  
  152. </script>
  153. </body>
  154. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement