How do I paginate my searched results here?

I’ve got a mysql database with a table having 3 columns “fname,lname & phone” I have created a search script which perfectly works but what I want is display only 2 data as in 2 rows per page from the ‘users’ table in the respected order! I’ve got around 8 rows, so there should be 4 pages with next & prev buttons! How do I do it?

here is my html form


<html>
    <head>
        <title>Search the Database</title>
    </head>
 
    <body>
 
    <form action="search4.php" method="post">
     Search: <input type="text" name="term" /><br />
    <input type="submit" name="submit" value="Submit" />
    </form>
 
    </body>
</html>

& here is search4.php

<?php
 
mysql_connect ("localhost", "root","")  or die (mysql_error());
mysql_select_db ("mydata");
 
 $term = $_POST['term'];
 
$sql = mysql_query("select * from users where fname like '%$term%'");
 
while ($row = mysql_fetch_array($sql)){

    echo '<br/> First Name: '.$row['fname'];
    echo '<br/> Last Name: '.$row['lname'];
    echo '<br/> Phone: '.$row['phone'];
    echo '<br/><br/>';
    }
 
?>
 
 

You might want to google for ‘pagination’, or do a search for it in this forum. There are lots of threads about it.