Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include('converte_data.php');
- //As tres 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;
- $limite = 4;
- $inicio = ($pagina * $limite) - $limite;
- $con = new PDO("mysql:host=localhost;dbname=album","root","");
- $registros = $con->query("SELECT COUNT(nome) count FROM imagem")->fetch()["count"];
- $paginas = ceil($registros / $limite);
- $result = $con->query("SELECT nome FROM imagem ORDER BY nome 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">
- <ul>
- <?php foreach ($result as $item): ?>
- <li><?=$item["nome"]?></li>
- <?php endforeach; ?>
- </ul>
- <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>
- </container>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement