Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Galeria</title>
- <style type="text/css">
- #principal{
- width: 650px;
- margin: auto;
- }
- body{
- font-family: Comic Sans ms;
- background-color: #fbeec1;
- }
- #listagem{
- border-color: black;
- background-color: white;
- color: black;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <?php
- $bd_host="localhost";
- $bd_user="root";
- $bd_password="";
- $bd_database="gf";
- $ni=$tit=$desc=$idt=$data=$foto='';
- $existe=false;
- $mysqli = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
- // Mostrar erros, caso existam
- if ($mysqli->connect_error) {
- die('Erro: ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
- }
- $msg="";
- ?>
- <h1>Galeria</h1>
- <form action="" method="post" enctype="multipart/form-data" name="frmi">
- <select name="listar" onchange="document.frmi.submit();" id="listagem">
- <option value="-1">SELECCIONE O TIPO A LISTAR</option>
- <?php
- $sqa="SELECT id_tipo,Tipo from tabela_tipo order by id_tipo";
- $statement = $mysqli->prepare($sqa);
- $statement->execute();
- $statement->bind_result($IDi,$tit);
- while($statement->fetch()) {
- echo '<option value="'.$IDi.'">'.$tit .'</option>';
- }
- ?>
- </select>
- </form>
- <?php
- if(isset($_POST["listar"]))
- {
- $qr = "SELECT foto from tabela_fotos where id_tipo=?";
- $results = $mysqli->query($qr);
- echo "<div id='principal'>";
- echo "<table id='tabela1' style='margin:auto' >";
- while ($row = $results->fetch_assoc()) {
- echo "<tr >";
- echo "<td >";
- ?>
- <img src="<?php echo $row['foto'];?>" width="200px">
- <?php
- echo "</td>";
- echo "<td >";
- if($row = $results->fetch_assoc()){
- ?>
- <img src="<?php echo $row['foto'];?>" width="200px">
- <?php
- echo "</td>";
- }
- echo "<td>";
- if($row = $results->fetch_assoc()){
- ?>
- <img src="<?php echo $row['foto'];?>" width="200px">
- <?php
- echo "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- echo "</div>";
- }
- ?>
- <?php
- $mysqli->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment