index.php
PHP Code:
<?php

include("function.paginationMain.php");
include(
"function.paginationLinks.php");

// This will be the main output
// echo paginationMain (10, "########", "#######", "123456789", "localhost", "pagination-table", "points");

// I've seperated the links so you can put them in where needed
// echo paginationLinks (10, "########", "#######", "123456789", "localhost", "pagination-table", "points");

?>
function.paginationMain.php
PHP Code:
<?php
function paginationMain ($perPage$DBname$DBuser$DBpass$DBhost$tableName$row)
{
    
// connect to database
    
$con = @mysql_connect($DBhost$DBuser$DBpass) or die(mysql_error());
    if(!
$db = @mysql_select_db($DBname$con)){die("Could not connect to database");}
    
// check table
    
$tableQuery mysql_query("SELECT * FROM `$tableName`") or die("Could not connect to table. `".$tableName."`"mysql_error());
    if(
mysql_num_rows($tableQuery)!=0)
    {
        
// get offset position
        
if(isset($_GET['nd']))
            
$end $_GET['nd'];
        else
            
$end $perPage;
        
// create main query
        
$query "SELECT * FROM `".$tableName."` ORDER BY ".$row." DESC LIMIT ".$perPage." OFFSET ".$end;
        
// get results
        
$resultsQuery mysql_query($query) or die(mysql_error());
        while(
$rows mysql_fetch_array($resultsQuery))
        {
            
###### EDIT BELOW HERE #####
            
$name $rows['name'];
            
$points $rows['points'];
            
            echo 
"<strong>name:</strong> ".$name." <strong>points:</strong> ".$points."<br />\n";
            
######    EDIT END    ######
        
}
    }
    else
    {
        
// here should be any code for if there currently is no data in table
        
return "No data available";
    }
    
mysql_close($con);
}
?>
function.paginationLinks.php
PHP Code:
<?php
function paginationLinks($perPage$DBname$DBuser$DBpass$DBhost$tableName$row)
{
    
// connect to database
    
$con = @mysql_connect($DBhost$DBuser$DBpass) or die(mysql_error());
    if(!
$db = @mysql_select_db($DBname$con)){die("Could not connect to database");}
    
// check table
    
$tableQuery mysql_query("SELECT * FROM `$tableName`") or die("Could not connect to table. `".$tableName."`"mysql_error());
    if(
mysql_num_rows($tableQuery)!=0)
    {
        
$numRows mysql_num_rows($tableQuery);
        
// get start position
        
if(isset($_GET['st']))
            
$start $_GET['st'];
        else
            
$start 0;
        
// get end position
        
if(isset($_GET['nd']))
            
$end $_GET['nd'];
        else
            
$end $perPage;
        
// create main query
        
$numPages ceil($numRows/$perPage);
        echo 
"<p>";
        if(
$start!=0)
        {
            if(((
$end-($perPage*2))+1)==1)
                
$prevS 0;
            else
                
$prevS = (($end-($perPage*2))+1);

            echo 
"<a href=\"".$_SERVER['PHP_SELF']."?st=".$prevS."&nd=".($end-$perPage)."\" title=\"previous\">[prev] </a> ";    
        }
        if(
$numPages>1)
        {
            for(
$x=0$x!=$numPages$x++)
            {
                if(((
$x*$perPage)+1)==1)
                    
$pageS 0;
                else
                    
$pageS = (($x*$perPage)+1);
                
                if((
$x+1)==($end/10))
                    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?st=".$pageS."&nd=".(($x*$perPage)+$perPage)."\" title=\"page ".($x+1)."\"> <strong>[".($x+1)."]</strong></a> ";
                else
                    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?st=".$pageS."&nd=".(($x*$perPage)+$perPage)."\" title=\"page ".($x+1)."\"> [".($x+1)."]</a> ";
            }
        }
        if(
$numPages>&& $end<$numRows)
        {
            if((
$end+1)==1)
                
$nextS 0;
            else
                
$nextS = ($end+1);
                
            echo 
"<a href=\"".$_SERVER['PHP_SELF']."?st=".$nextS."&nd=".($end+$perPage)."\" title=\"next\"> [next]</a> ";    
        }
        echo 
"</p>\n";
    }
    
mysql_close($con);
}
?>
For more info and demo, please visit:

http://www.actwebdesigns.co.uk/web-d...n-function.php