I am trying to encode a small swap system, but as far as I understand, I am getting an error. Here is my code:
<!-- something before that working well -->
else{
include('head.php');
if(empty($_GET['pg'])){ $_GET['pg'] = 0 ;}
$offset = $_GET['pg'] * 5;
$query = $db->prepare('SELECT * FROM posts ORDER BY id DESC LIMIT 5 OFFSET :n');
$query->bindParam(':n', $offset);
$query->execute();
?>
<body>
<?php
while ($data = $query->fetch()){
echo '<article>'.$data['content'].'</article>';
}}?>
</body>
So I just want to display 5 articles per page. That is, I want the last 5 articles on the index page (i.e. page 0), then the next 5 articles on page 1, etc. So far, all I get is an error:
: "PDOException" "SQLSTATE [42000]: : 1064 SQL; , MySQL, '' 0 '' 1 '/Applications/MAMP/htdocs/index.php:24 : # 0/Applications/MAMP/htdocs/index.php(24): PDOStatement- > () # 1 {main} /Applications/MAMP/htdocs/index.php 24
24 - $query->execute();.
, , : ? , ?