its ok now i finally got the whole script working perfectly. below is the whole script but only missing the config.php file. I hope someone else in future can make some use of this script because i spent days on the internet looking for such a script in php5 or higher and found nothing but crappy simple ones. here is the finished scrip.
[PHP]
Papermashup.com | PHP Pagination
.paginate {
font-family:Arial, Helvetica, sans-serif;
padding: 3px;
margin: 3px;
}
.paginate a {
padding:2px 5px 2px 5px;
margin:2px;
border:1px solid #999;
text-decoration:none;
color: #666;
}
.paginate a:hover, .paginate a:active {
border: 1px solid #999;
color: #000;
}
.paginate span.current {
margin: 2px;
padding: 2px 5px 2px 5px;
border: 1px solid #999;
font-weight: bold;
background-color: #999;
color: #FFF;
}
.paginate span.disabled {
padding:2px 5px 2px 5px;
margin:2px;
border:1px solid #eee;
color:#DDD;
}
li {
padding:4px;
margin-bottom:3px;
background-color:#FCC;
list-style:none;
}
ul {
margin:6px;
padding:0px;
}
<?php
require('includes/config.php');
$targetpage = 'pagination.php';
$limit = 3;
$stmt = $db->prepare("SELECT COUNT(*) as num FROM members");
$stmt->bindParam(':members', $q, PDO::PARAM_INT);
$stmt->execute();
$total_pages = $stmt->fetchColumn(0);
$stages = 3;
$page = (isset($_GET["page"])) ? (int)$_GET["page"] : 1;
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
$sql = “SELECT * FROM members LIMIT $start, $limit”;
foreach ($db->query($sql) as $row) {
}
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
$paginate = ‘’;
if($lastpage > 1)
{
$paginate .= “
”;
// Previous
if ($page > 1){
$paginate.= “
previous”;
}else{
$paginate.= “
previous”; }
// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= “
$counter”;
}else{
$paginate.= “
$counter”;}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= “
$counter”;
}else{
$paginate.= “
$counter”;}
}
$paginate.= “…”;
$paginate.= “
$LastPagem1”;
$paginate.= “
$lastpage”;
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
$paginate.= “
1”;
$paginate.= “
2”;
$paginate.= “…”;
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if ($counter == $page){
$paginate.= “
$counter”;
}else{
$paginate.= “
$counter”;}
}
$paginate.= “…”;
$paginate.= “
$LastPagem1”;
$paginate.= “
$lastpage”;
}
// End only hide early pages
else
{
$paginate.= “
1”;
$paginate.= “
2”;
$paginate.= “…”;
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= “
$counter”;
}else{
$paginate.= “
$counter”;}
}
}
}
// Next
if ($page < $counter - 1){
$paginate.= “
next”;
}else{
$paginate.= “
next”;
}
$paginate.= “
”;
}
// pagination
echo $paginate;
?>
<?php
foreach ($db->query($sql) as $row)
{
echo '- '.$row['username'].' '.$row['urank'].'
';
}
echo $paginate;
?>
[/PHP]
I really appreciate all the replies and help but i ended up getting a little help from a php facebook group, thanks again