I'm quite new to OOP and PDO and have been unable to figure out how to show MYSQL results by pages (e.g 10 per page). What would be the best way to do this?
public function getResults() {
try {
$con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sql = "SELECT * FROM table ORDER BY id DESC LIMIT 10";
$result = $con->query($sql);
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
$msg_id = $row['id'];
echo '<div id="results">' .$msg_id. '</div>';
}
$con = null;
}catch(PDOException $e) {
echo $e->getMessage();
}
}
}