<?php
include_once ("config.php");
$pagesleft = $total_pages - $current_page;
if (($current_page - 5 >= 0) && ($current_page + 5 <= $total_pages)){
$startcounter = $current_page -5;
$stopcounter = $current_page + 5;
}
if (($current_page - 6 >= 0) && ($current_page + 4 == $total_pages)){
$startcounter = $current_page -6;
$stopcounter = $current_page + 4;
}
if (($current_page - 7 >= 0) && ($current_page + 3 == $total_pages)){
$startcounter = $current_page -7;
$stopcounter = $current_page + 3;
}
if (($current_page - 8 >= 0) && ($current_page + 2 == $total_pages)){
$startcounter = $current_page -8;
$stopcounter = $current_page + 2;
}
if (($current_page - 9 >= 0) && ($current_page + 1 == $total_pages)){
$startcounter = $current_page -9;
$stopcounter = $current_page + 1;
}
if (($current_page - 10 >= 0) && ($current_page == $total_pages)){
$startcounter = $current_page -10;
$stopcounter = $current_page;
}
if (($current_page - 20 <= 0)){
$startcounter = 1;
if ($total_pages >=20){
$stopcounter = 20;
}else{
$stopcounter = $total_pages;
}
}
//start counting and listing pages
for ($counter = $startcounter; $counter <= $stopcounter; $counter += 1) {
$pagination_html = $pagination_html.'[*]
'.$counter.'';
}
//create << previous and >>next list
if ($pl == true) {
$pl = '[*]
'.$config['pagination_previous'].'';// << previous and next
}
else {
$pl = '';// << no previous and next
}
if ($nl == true) {
$nl = '[*]<a href="'.$url.'?page='.$next_page.$additional_url_v ariable.
'">'.$config['pagination_next'].'</a>';// >> previous and next
}
else {
$nl = '';// >> no previous and next
}
$show_pages = $pl.$pagination_html.$nl;//note $total_pages is not same as one used in fucntion above, i have high jacked is because already in array
?>