Home  >  Article  >  Backend Development  >  The paging function I just wrote_PHP tutorial

The paging function I just wrote_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:51:53738browse




The paging function I just wrote
Solution
I originally wanted to find a paging function or class to use, but after searching for a long time on the Internet, I couldn't find anything easy to use. I spent 10 minutes on my own to create a paging function. It's very simple, and I'll give you a review.... (See later It’s a bit similar to Google and Baidu....) /*Paging function

$num:How many articles in total

$p:Current page number

$q: Current search content

$str: address url parameter (the thing after the question mark)

$pn: Display quantity per page

{fl($num,$p,$q,$pn)}

*/

function fy($num,$p,$str='?mod=zzwla&dosubmit=1',$q='',$pn=10)

{

if(empty($num)) return false;

$ps=ceil($num/$pn);

$q = $q ? '&q='.urlencode($q) : '';

if($p>1)

echo 'Previous page';

if($ps
for($i=1;$i
{

if($i
echo ' '.$i.' '):('page"> '.$i.' ')).'';

}

else

for($i=$p7;$i
{

if($i>0 && $i
echo ' '.$i.' '):('page"> '.$i.' ')).'';

}

if($p!=$ps)

echo 'next page';

}


Copy the code and below is the screenshot, haha ​​








[ ]
Attachment: Your user group cannot download or view attachments

D8888D’s reply content
Take a look at the pagination class written by the old ghost

[url=http://bbs.phpchina.com/viewthread.php?tid=29479&highlight=%B7%D6%D2%B3]Link tag http://bbs.phpchina.com/viewthre ... hlight=%B7 %D6%D2%B3[/url]
D8888D’s reply content
I saw it, one character long
It’s ok if you can quickly implement the function
D8888D’s reply content
I use the icon on the editor, and when previewing I only see a pair of [CODE] tags at both ends of the code.
D8888D’s reply content
Used it. Thank you
D8888D’s reply content
Thanks for sharing @!
D8888D’s reply content
Used them all
^_^
[img]http://www.phpchina.com/bbs/images/smilies/default/lol.gif[/img]

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632524.htmlTechArticleThe paging function solution I just wrote. I wanted to find a paging function or class to use, but I found it online. After a long time, I couldn’t find anything simple to use. I just spent 10 minutes to create a paging. It’s very simple...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn