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.