开发者

Pagination for PHP search results

How can i form开发者_JAVA技巧at pages in following manner? eg my search results gave me data for 50 pages. then i want this format for pages.

page1 page2 page3 page4 page5 .... page50

also when i click on '....' the result should be returned from page6 and the page listing should be like

page1 .... page5 page6 page7 page8 page9 .... page50

i hope i am clear with my question


First calculate total number of records with its search criteria. Then divide it with record per page. So you will get Total Pages to show. say for eg

$total_number_record = 30; 
$record_per_page = 10; 
$total_pages = 30/10; (3) 

Now use loop to show links

for($i=1;$i<=$total_pages;$i++){ 

    echo '<a href=\'search.php?page="'.$i.'"&search="'. $_POST['search'].'">Page '.$i.'</a>';

} 

this will shows link on your web page


I think you will find all answers on this page:

http://phpeasystep.com/phptu/29.html


http://phpeasystep.com/phptu/29.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜