Pagination of products with PDO [duplicate]

-1

I need to create a page for my database with 180 products, but images without paging appear all 180 side by side, how can I limit the 10 images per page side by side?

Here's my code:

<?php
echo'<table width="88%" height="10" cellspacing="0" cellpadding="0"><tr>';
$conn = new PDO("mysql:host=localhost;dbname=loja", "root", "");
$stmt = $conn->prepare("SELECT * FROM 'produtos' ORDER BY 'id' ASC ");
$stmt->execute( );
$linha = $stmt->fetch(PDO::FETCH_ASSOC);
while($linha = $stmt->fetch(PDO::FETCH_ASSOC)) {
    echo'<br>';
    echo'<p><td align=center ><h2><font size="5" face="Trebuchet MS">'.$linha['nome'].'</font></font></p></h2>';
    echo "<div align=center ><img src='".$linha['foto']."' width='160' height='160' border='0'></p>";
    echo '<a href="carrinho.php?acao=add&id='.$linha['id'].'"><button type="button" name="" value="" class="quero">Eu Quero!</button>';
}
echo "</tr></table>";
?>
    
asked by anonymous 28.09.2015 / 20:16

1 answer

0

To limit the number of records in a query, use the LIMIT clause. / p>

SELECT * FROM 'produtos' ORDER BY 'id' ASC LIMIT 10
    
28.09.2015 / 20:44