I've never used SQL functions, and have no idea how to implement this. Can you provide example PHP code to demonstrate please?
This is what I have at the moment:
$sqlconnection = "host=localhost user=nobody dbname=david-dblog";
$conn = pg_connect($sqlconnection) or die("Unable to connect to database server");
$sql= "SELECT * FROM data ORDER BY id DESC LIMIT 2 OFFSET 2"; // The limit and offset are generated dynamically
$result_set = pg_Exec($conn, $sql);
// And then deal with that $result_set