Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!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 href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
- <link rel="stylesheet" href="css/style.css">
- <title>Galeria de imagens</title>
- </head>
- <style>
- body {
- font-family: 'Poppins', sans-serif;
- font-size: 15px;
- }
- </style>
- <body>
- <br>
- <div class="container">
- <h4>Listagem de fotos</h4>
- <a href="form_upload.php">Subir imagem</a> | <a href="form_search.php">Pesquisar imagem</a>
- <br><br><br>
- <div class="row">
- <?php
- $pdo = new PDO('mysql:host=______;dbname=__________', 'usuario', 'senha');
- $stmt = $pdo->prepare("SELECT id, name, arquivo FROM tabimagem ORDER BY id DESC");
- $stmt->execute();
- $images = $stmt->fetchAll();
- $i = 0;
- $total_images = count($images);
- $current_page = isset($_GET['page']) ? intval($_GET['page']) : 1;
- $images_per_page = 12;
- $total_pages = ceil($total_images / $images_per_page);
- $start = ($current_page - 1) * $images_per_page;
- $images = array_slice($images, $start, $images_per_page);
- foreach($images as $image):
- ?>
- <div class="col-12 col-md-3">
- <div class="shadow p-3 mb-5 bg-white rounded">
- <!--<img src="<?php echo $image['arquivo']; ?>" class="img-fluid">-->
- <a href="<?php echo $image["arquivo"]; ?>" target="_blank"><img src="<?php echo $image["arquivo"]; ?>" width="100%" class="img-fluid"></a>
- <?php echo $image['name']; ?>
- </div>
- </div>
- <?php
- $i++;
- if($i % 12 == 0 && $i != 0){
- echo '</div><div class="row">';
- }
- endforeach;
- ?>
- </div>
- <div class="text-center">
- <ul class="pagination">
- <?php for($i = 1; $i <= $total_pages; $i++): ?>
- <li class="page-item <?php if($current_page == $i) echo 'active'; ?>">
- <a class="page-link" href="index.php?page=<?php echo $i; ?>"><?php echo $i; ?></a>
- </li>
- <?php endfor; ?>
- </ul>
- </div>
- </div>
- <div class="rodape-site">
- Mizuno © 2023
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement