Code:
if (!$_GET['page'] && !ctype_digit($_GET['page'])) {
throw new Exception('page number must be digit');
}
$page = $_GET['page'];
$limit = 5;
$max = 'limit ' .($page - 1) * $limit .',' .$limit;
$data_p = "SELECT * FROM testtable $max";
$result_2 = mysql_query($data_p);
while ($list = mysql_fetch_assoc($result_2)) {
// echo data
echo $list['random'] . "<br />";
}
i don't have pdo setup correctly on my test server, but this code worked for me. just replace the table name / row name in this code.