Php implements the code for the previous and next pages of the article-PHP source code

Source: Internet
Author: User
Ec (2); php implements the code for the previous and next pages of the article. This is used when I want to write a small file. I will share it with you today, I remember my previous thoughts on how to implement the next page in the article. Later I saw in a BBS that it was to judge the current ID and then orderby or asc can be simply implemented. functionnextpage ($ fid, $ tag, $ bid) {& nbsp; if (next $ tag) {& script ec (2); script

Php implements the code for the previous and next pages of the article. This is used when I want to write a small file. I will share it with you today, I remember my previous thoughts on how to implement the next page in the article. Later I saw in a BBS that it was originally to judge the current ID and then order by or asc can be simply implemented.

Function nextpage ($ fid, $ tag, $ bid ){
If ('Next' = $ tag ){
$ SQL = "select * from gx_news where id <$ fid and menu_id = '$ bid' order by id desc ";
} Elseif ('prev' ==$ tag ){
$ SQL = "select * from gx_news where id> $ fid and menu_id = '$ bid' order by id asc ";
}
$ Result = mysql_query ($ SQL );
If (! Mysql_num_rows ($ result )){
Echo ('no more! ');
} Else {
$ Rs = mysql_fetch_array ($ result );
Echo "". $ rs ['new _ title']. "";
}
}

Well, the code is actually very easy. I don't want to talk about it. I just want to show the beginners how to implement the previous and next pages of the article.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.