I am trying to limit the shown pagination




<?php

$per_page = 5;

$pages_query = mysql_query("select count('pub_id') from publikimet ");
$pages = ceil(mysql_result($pages_query,0) / $per_page);
$page = (isset($_GET['page']))? (int) $_GET['page']: 1;
$start = ($page - 1)* $per_page;
$query=mysql_query ("select * from publikimet  inner join kategorite on cat_id=category_id
inner join vendet on vendi_id=vendet_id where aprovuar=1 limit $start,$per_page");
while ($query_row = mysql_fetch_assoc($query)){

$pub_id=$query_row['pub_id'];
$titulli=$query_row['titulli'];
$data=$query_row['data'];
$foto=$query_row['foto'];
$qmimi=$query_row['qmimi'];
$vendi_title=$query_row['vendi_title']; 
$cat_title=$query_row['cat_title'];
$memarrveshje=$query_row['memarrveshje'];


echo "/////////"
};






$prev = $page - 1;
$next = $page +1 ;
if(!($page<=1)){


echo "<a style='color:white;text-decoration:none;padding:1px 3px 6px 3px;margin-top:-10px;
;background-color:#F07830; margin-left:110px;
'
href='shpalljet.php?page=$prev'>Previous</a>";
}


if($pages >= 1){

for($x=1;$x<=$pages;$x++){

echo '<div class="pagination"><b><a href="?page='.$x.'">'.$x.'</a></div>';

}

}
if(!($page>=$pages)){
echo "<a style='color:white;text-decoration:none;padding:1px 3px 6px 3px;margin-top:-10px;
;background-color:#F07830;'
href='shpalljet.php?page=$next'>Next</a>";

}



?>