Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include('converte_data.php');
- //As linhas abaixo são a paginação
- $pagina = 1;
- if (isset($_GET['pagina']))
- $pagina = filter_input(INPUT_GET, "pagina", FILTER_VALIDATE_INT);
- if (!$pagina)
- $pagina = 1;
- // Numero de registros por página
- $limite = 3;
- $inicio = ($pagina * $limite) - $limite;
- $con = new PDO("mysql:host=sql113.epizy.com;dbname=epiz_30185854_listagem","epiz_30185854","m8MJmldvSuKEFX");
- $registros = $con->query("SELECT COUNT(nome) count FROM imagem")->fetch()["count"];
- $paginas = ceil($registros / $limite);
- $result = $con->query("SELECT * FROM imagem ORDER BY id DESC LIMIT $inicio, $limite")->fetchall();
- //var_dump($result);
- ?>
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <link rel="preconnect" href="https://fonts.googleapis.com">
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
- <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
- <link rel="stylesheet" href="css/style.css">
- <title>Galeria</title>
- </head>
- <style>
- body {
- font-family: 'Poppins', sans-serif;
- font-size: 15px;
- }
- </style>
- <body>
- <br><br>
- <div class="container">
- <h5>
- <a href="?pagina=1">Primeira</a>
- <?php if ($pagina>1): ?>
- <a href="?pagina=<?=$pagina-1?>"><<</a>
- <?php endif; ?>
- <?=$pagina?>
- <?php if ($pagina<$paginas): ?>
- <a href="?pagina=<?=$pagina+1?>">>></a>
- <?php endif; ?>
- <a href="?pagina=<?=$paginas?>">Última</a></h5>
- <!--<?php foreach ($result as $foto): ?>-->
- <br><br>
- <div class="row">
- <?php
- $cont = 0;
- foreach ($result as $foto) {
- $cont++;
- ?>
- <div class="col-sm-4">
- <div class="shadow p-3 mb-5 bg-white rounded">
- <?php echo converte_data($foto['data']); ?><br>
- <?php echo "".$foto["assunto"]?><br>
- <a href="<?php echo $foto["url"]; ?>" target="_blank"><img src="imagens/<?php echo $foto["nome"]; ?>" width="100%" class="img-fluid"></a><br>
- <div class="descricao">
- <!--<?php echo "".$foto["descricao"]?><br>-->
- <?php echo substr(nl2br($foto['descricao']), 0, 43); ?>...
- </div>
- <!--<?php echo "<a href=". $foto['url'] ." target='_blank'> <b>Acessar</b></a><br>"?>-->
- </div>
- </div>
- <?php
- if($cont ==3){
- echo "</div>";
- echo "<div class='row'>";
- $cont = 0;
- }
- }
- ?>
- </div>
- <!-- <?php endforeach; ?>-->
- <h5>
- <a href="?pagina=1">Primeira</a>
- <?php if ($pagina>1): ?>
- <a href="?pagina=<?=$pagina-1?>"><<</a>
- <?php endif; ?>
- <?=$pagina?>
- <?php if ($pagina<$paginas): ?>
- <a href="?pagina=<?=$pagina+1?>">>></a>
- <?php endif; ?>
- <a href="?pagina=<?=$paginas?>">Última</a></h5>
- <br><br><br><br>
- </container>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement