johnhey 0 Denunciar post Postado Junho 19, 2015 Boa tarde pessoal estou tentando fazer uma paginação, esta tudo igual ao video que vi, mas não esta a funcionar, da o seguinte erro. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /htdocs/public/www/adotados.php on line 133 este é o código: <?php // Criando conexão $link = mysql_connect('hostingmysql243.amen.pt', 'BD', '123456'); if (!$link) { die('Não foi possÃvel conectar: ' . mysql_error()); } //echo 'Conexão bem sucedida'; $db_selected = mysql_select_db('rebornimaginacoesdebebes_com_pt_bdreborn', $link); $limite = 8; $SQL_COUNT = mysql_query("SELECT COUNT('Registo') from bebes"); $SQL_RESUL = ceil(mysql_result($SQL_COUNT, 0) / $limite); $PG = (ISSET($_GET["pg"])) ? (int)$_GET["pg"] : 1; $inicio = ($pg - 1) * $limite; $sql=mysql_query("SELECT * FROM bebes LIMIT $inicio, $limite ORDER BY Registo asc"); while ($linha = mysql_fetch_array($sql)){ $nome = $linha['Nome']; $foto = $linha['Foto']; echo "<li> <a href='$nome.html' title='$nome'><img src='imagens/miniatura/$foto' width='100' height='80' alt='$nome'></a> </li>";} ?> Compartilhar este post Link para o post Compartilhar em outros sites
angelorubin 142 Denunciar post Postado Junho 19, 2015 Veja se ajuda: https://github.com/onassar/PHP-Pagination https://github.com/whiteoctober/Pagerfanta https://github.com/usmanhalalit/strana#installation O ultimo é integrado com twitter bootstrap, veja: https://drive.google.com/file/d/0B8qZzpnQFKOVblZTd2l2TGFYWGM/view?pli=1 Exemplo de código: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Pagination PHP</title> <!-- Latest compiled and minified CSS & JS --> <link rel="stylesheet" media="screen" href="//netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <script src="//code.jquery.com/jquery.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <style type="text/css" media="screen"> .table { margin-top: 1em; margin-bottom: -0.1em; } </style> </head> <body> <div class="container"> <div class="row"> <table class="table table-bordered table-striped"> <th>Itens</th> <?php // Make sure you have Composer's autoload file included require '../../vendor/autoload.php'; $strana = new \Strana\Paginator(); $records = array( 1 => 'Item 1', 2 => "Item 2", 3 => "Item 3", 4 => "Item 4", 5 => "Item 5", 6 => "Item 6", 7 => "Item 7", 8 => "Item 8", 9 => "Item 9", 10 => "Item 10" ); $paginator = $strana->perPage(3)->make($records); // Loop paginated items foreach ($paginator as $item) { ?> <tr> <td><?php echo $item ?></td> </tr> <?php } ?> </table> </div> <div class="row"> <?php // Print pagination links echo $paginator; ?> </div> </div> </body> </html> Compartilhar este post Link para o post Compartilhar em outros sites
ESerra 744 Denunciar post Postado Junho 19, 2015 O problema é a consulta: $sql=mysql_query("SELECT * FROM bebes LIMIT $inicio, $limite ORDER BY Registo asc"); O ORDER BY tem que vir antes do LIMIT... Compartilhar este post Link para o post Compartilhar em outros sites