Hi Friends,

I am trying to limit the number of pages to display on my code. Can someone please help?
I am trying to get something like http://stackoverflow.com/questions/8361808/limit-pagination-page-number

$Num_Rows = mysql_num_rows($objQuery);




$Per_Page = 15;   // Per Page



$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}

$Prev_Page = $Page-1;
$Next_Page = $Page+1;

$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}





$strSQL .=" order by adid  DESC LIMIT $Page_Start , $Per_Page  ";
$objQuery  = mysql_query($strSQL);

?>

<?
while($objResult = mysql_fetch_array($objQuery))
{
?>


<div style="margin-left:64px; margin-right:64px;"  >




 <span class='urllink'>  <a href="viewad.php?adid=<?=$objResult['adid'];?>"> <?=$objResult["title"];?>  - <?=$objResult["age"];?> </a> <span>    (<?=$objResult["location"];?>) <br>  <br> <b>Service Type:</b> <?=$objResult["servicetype"];?> <br> <b>Height:</b> <?=$objResult["height"];?> <br> <b>Body Type:</b> <?=$objResult["bodytype"];?>

  <hr  width="64%" align="left"/>

</div>
<?
}
?>
</table>

<div style="margin-left:58px; margin-right:58px;  padding:6px; background-color:#FFF;  font-size:20px; margin-top: 60px; text-shadow: 2px 2px 3px gray  ">
<span class="paginationNumbers">
<?
if($Prev_Page)
{
echo  " &nbsp;<a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]&category=$_GET[category]'  class='pagNumActive' ><< Back</a>  &nbsp; ";
}

for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "&nbsp; <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]&category=$_GET[category]'  class='pagNumActive'>$i</a>&nbsp; ";
}
else
{
echo " <span class='pagNumActivelink'> $i </span> ";
}
}
if($Page!=$Num_Pages)
{
echo "&nbsp; <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]&category=$_GET[category]' class='pagNumActive'  >Next>></a>&nbsp; ";
}

mysql_close($objConnect);
}
?>

The link you posted has all the code you need, so what's the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.