How to add a pager to the page with php?

I’m new to PHP and I’d like to add a pagination function to the page.

I have this piece of code:

$result = mysql_query( "select title from post LIMIT 5 OFFSET 0");
while ($row = mysql_fetch_object($result)) {
    echo $row->title;
}

$total is all the rows.

I’d like to show only five post titles per page. If I want to add a pager to this page, how do I do this? E.g: the URL is example.com/post.html.

well it shouldnt be .html or the PHP engine shouldnt be parsing it :wink:

pagination can be calculated with as little as a single URL variable;
test.php?page=1

From there you can calculate your start point ((page - 1) * sizeofpages) [assuming you’re using page 1 as your 0-index]
your size is defined by the code;
The resulting query would be SELECT … LIMIT <startpoint>,<sizeofpage>

To generate the nav takes a bit more calculation, but there’s plenty of pagination scripts out there already written…