//rows per page
$rpp =10;
extract($_GET);
$pagNum = isset($pagNum) ? $pagNum : '1';
//headlers for your query results
echo '
<table name="display" align="center" cellspacing=0 cellpadding=3>
<tr>
<th width=30 align=center>As</th>
<th width=100 align=center>many</th>
<th width=30 align=left>as</th>
<th width=50 align=left>You</th>
<th width=100 align=left>need</th>
</tr>';
$db_query=mysql_query("SELECT * FROM table WHERE id LIKE '%' ORDER BY id ASC ");
$totalRows = mysql_numrows($db_query);
$rowFrom = ($pagNum * $rpp) - ($rpp - 1);
$rowTo = $pagNum * $rpp;
if ($rowFrom > $totalRows) {$rowTo = $totalRows;}
$numRow = 1;
while ($numRow < $rowFrom)
{
$db_Row=mysql_fetch_array($db_query);
++ $numeroRow;
}
//this is to display the info. The name of the variables would be the name of the fields on MySQL
while (($numRow >= $rowFrom) and ($numRow <= $rowTo))
{
$db_Row=mysql_fetch_array($db_query);
extract($db_Row);
<tr>
<td align=center><b><small>' . $numRow . '</small></b></td>
<td align=center>' . $content. '</td>
<td align=left>' . $from . '</td>
<td align=left>' . $MySQL . '</td>
<td align=left>' . $table . '</td>
</tr>';
++ $numRow;
}
echo '</table>';
//optional footnote
if (mysql_numrows($db_query) != 0){
echo '<small>Showing = ' , $rowTo - $rowFrom + 1 , ' (from ' . $rowFrom . ' to' . $rowTo . ')';}
echo '<br /><br />';
//getting the total of pages
if ($rpp < $totalRows) {
$totalPages = ceil($totalRows/$rpp);
echo 'Page ' . $pagNum . ' of ' . $totalPages . '<br /><br />';
if ($pagNum > 1) {echo '<a href="?pagNum=' , $pagNum - 1 , '">< PREVIOUS</a> ';}
else {echo '< PREVIOUS ';}//with no link option, is there is no previous page
$numPage = 1;
while ($numPage <= $totalPages)
{
if ($numPage == $pagNum){echo $numPage . ' ';}
else {echo '<a href="?pagNum=' . $numPage . '">' . $numPage . '</a> ';}
++ $numPage;
}
if ($pagNum < $totalPages) {echo ' <a href="?pagNum=' , $pagNum + 1 , '"> NEXT ></a>';}
else {echo ' NEXT >';}//no link as there it is already the last page
echo '<br /><br />';
echo '<a href="?pagNum=1">first page</a> - <a href="?pagNum=' . $totalPages . '">last page</a></small>';
}