0

i am facing problem, my php show all pages in row and its increasing day by day as i upload data on my sql. I just want 25 page result on page and other for click to next.

<?php

if(isset($page))

{

$result = mysql_query("select Count(*) As Total from store_urls");

$rows = mysql_num_rows($result);

if($rows)

{

$rs = mysql_fetch_assoc($result);

$total = $rs["Total"];

}

$totalPages = ceil($total / $perpage);

if($page <=1 ){

echo "<span id='page_links' style='font-weight: bold;float:left;'>Prev</span>";

}

else

{

$j = $page - 1;

echo "<span style='float:left;'><a style='padding: 8px;' id='page_a_link' href='url_lists.php?page=$j'>< Prev</a></span>";

}

for($i=1; $i <= $totalPages; $i++)

{

if($i<>$page)

{

echo "<span><a style='float:left;padding: 8px;' id='page_a_link' href='url_lists.php?page=$i'>$i</a></span>";

}

else

{

echo "<span id='page_links' style='font-weight: bold;float:left;'>$i</span>";

}

}

if($page == $totalPages )

{

echo "<span id='page_links' style='font-weight: bold;'>Next ></span>";

}

else

{

$j = $page + 1;

echo "<span><a id='page_a_link' style='float:left;padding: 8px;' href='url_lists.php?page=$j'>Next</a></span>";

}

}

?>
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
  • http://www.tutorialspoint.com/php/mysql_paging_php.htm – Tushar Gupta - curioustushar Mar 15 '14 at 02:44
  • [The mysql extension is deprecated](http://www.php.net/manual/en/function.mysql-query.php). You should switch to [MySQLi](http://www.php.net/manual/en/book.mysqli.php) or [PDO](http://www.php.net/manual/en/ref.pdo-mysql.php). – TimWolla Mar 15 '14 at 02:44
  • 10 next pages for($i = $page + 1; $i <= min($page + 11, $total_pages); $i++) or if you want 5 prev and 5 next for($i = max(1, $page - 5); $i <= min($page + 5, $total_pages); $i++) thanks to original post`http://stackoverflow.com/questions/3036909/pagination-10-pages-per-page?rq=1` – user3107746 Mar 15 '14 at 03:35

0 Answers0