Giihh 6 Denunciar post Postado Março 25, 2016 Olá Estou tentando criar uma paginação com imagens que estão no DB conforme imagem abaixo: No .htaccess eu configurei para capturar o $ _GET [ 'pagination'] Tabela IMAGES esta assim: id_images | dir_image | post_id 1 image1.jpg 1 2 image2.jpg 1 3 image3.jpg 1 4 image4.jpg 1 5 image5.jpg 2 6 image6.jpg 2 7 image7.jpg 2 8 image8.jpg 2 Tabela POSTS: id_post | slug | title 1 title_post Title Post 2 title_post_2 Title Post 2 PHP $maximo = 1; $pagination= isset($_GET['pagination']) ? ($_GET['pagination']) : '1'; $pagination2 = $pagination + 1; $init = $pagination - 1; $init = $maximo * $init; $strCount = "SELECT COUNT(*) AS 'total_images' FROM posts, images WHERE posts.id_posts = images.posts_ID AND slug='".$_GET['slug']."'"; $varstrCount = try { $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $this->db->prepare($strCount); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { die('Error: ' . $e->getMessage() ); } $total = 0; if(count($varstrCount)){ foreach ($varstrCount as $row) { $total = $row["total_images"]; } } $result = "SELECT * FROM posts, images WHERE posts.id_post = images.posts_ID AND slug='".$_GET['slug']."' ORDER BY id_posts LIMIT $init,$maximo"; $varresult = try { $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $this->db->prepare($result); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { die('Error: ' . $e->getMessage() ); } $max_links = 10; $previous = $pagination - 1; $next = $pagination + 1; $pgs = ceil($total / $maximo); for($i=$pagination-$max_links; $i <= $pgs; $i++) { if($i == $pgs){ echo "<img src='".BASE_URL.$row['images_dir']."' >"; } }else{ echo "<a href='".BASE_URL.$slug."-".($i)."'><img src='".BASE_URL.$row['images_dir']."' ></a>"; } } Isso foi o máximo que estou conseguindo Mas no "for" não esta funcionando para imprimir corretamente o menu de imagens . E outra questão: como faço para que a imagem ativada seja exibida em um tamanho grande? PS. Imagem, Código e tabelas em inglês pq perguntei em outro fórum também. Agradeço ajuda Compartilhar este post Link para o post Compartilhar em outros sites