Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pt" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title>Galeria</title>
- <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">
- <style media="screen">
- .titulo{
- text-align: center;
- }
- td:hover{
- background-color: blue;
- }
- </style>
- </head>
- <body>
- <?php
- include"cabecalho.php";
- $bd_host="localhost";
- $bd_user="root";
- $bd_password="";
- $bd_database="galeria";
- $tipo="";
- $msg="";
- $erro=0;
- $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
- $existe=false;
- if ($ms->connect_error) {
- $msg= '<h3 class="erro">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
- $erro=1;
- }
- ?>
- <?php
- $qr = "SELECT imagem from tbl_fotos";
- $results = $ms->query($qr);
- echo "<h1 class='titulo'>TODAS AS FOTOS</h1>";
- echo "<div id='ftt'>";
- echo "<table style='margin:auto' colspan='2'>";
- while ($row = $results->fetch_assoc()) {
- echo "<tr>";
- echo "<td>";
- ?>
- <img src="<?php echo $row['imagem'];?>" width="200px">
- <?php
- echo "</td>";
- echo "<td>";
- if($row = $results->fetch_assoc()){
- ?>
- <img src="<?php echo $row['imagem'];?>" width="200px">
- <?php
- echo "</td>";
- }
- echo "<td>";
- if($row = $results->fetch_assoc()){
- ?>
- <img src="<?php echo $row['imagem'];?>" width="200px">
- <?php
- echo "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- echo "</div>";
- ?>
- <?php
- if (isset($_POST['pesq']))
- {
- $qr="SELECT tipo FROM tbl_tipo where tipo=?";
- $st=$ms->prepare($qr);
- $st->bind_param('s', $_POST["num"]);
- $st->execute();
- $st->bind_result($tipo);
- if($st->fetch())
- $st->close();
- $qro="SELECT imagem from tbl_fotos inner join tbl_tipo on tbl_fotos.tipo=tbl_tipo.tipo WHERE tbl_fotos.tipo='$tipo'";
- $results = $ms->query($qro);
- echo "<div>";
- echo "<h1 class='titulo'>Fotos por tipo selecionado</h1>";
- echo "<table style='margin:auto'>";
- while ($row1 = $results->fetch_assoc()) {
- echo "<tr>";
- echo "<td>";
- ?>
- <img src="<?php echo $row1['imagem'];?>" width="200px">
- <?php
- echo "</td>";
- echo "<td>";
- if($row1 = $results->fetch_assoc()){
- ?>
- <img src="<?php echo $row1['imagem'];?>" width="200px">
- <?php
- echo "</td>";
- }
- echo "<td>";
- if($row1 = $results->fetch_assoc()){
- ?>
- <img src="<?php echo $row['imagem'];?>" width="200px">
- <?php
- echo "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- echo "</div>";
- }
- ?>
- <form class="" action="" method="post" name="tiposs">
- <input type="hidden" name="pesq" value="1">
- <br><br>
- <h4 style="text-align:center">Tipo<select name="num" onchange="muda()">
- <option value=""></option>
- <?php
- $qr="SELECT tipo FROM tbl_tipo";
- $st = $ms->query($qr);
- while($row = $st->fetch_assoc())
- {
- echo '<option value = "'.$row['tipo'].'">'.$row['tipo'].' </option>';
- }
- $st->close();
- ?>
- </select></h4>
- <br><br>
- </form>
- <?php include"rodape.php"; ?>
- <script>
- function muda(){
- document.tiposs.submit();
- document.getElementById("ftt").style.visibility="hidden";
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement