Php retrieves the previous and next pages of an article. Php: how to obtain the previous and next pages of an article. This document describes how to obtain an article by using php. Share it with you for your reference. The specific method is as follows: today I found a site asking php to obtain the previous and next pages of the article.
The example in this article describes how to get an article from php. Share it with you for your reference. The specific method is as follows:
I found a problem with a website today. I went directly to the latest article published on this channel. The principle should be that the first and last IDs of the article ID are the top and bottom pages, the following is a detailed description.
Let's take a look at the example below: 1, 2, 3, 4, 5.
If the five above are IDs, the order we want to use order by ID asc should be 4. The principle is so simple.
The code is as follows:
:
The code is as follows: $ SQL = "Select field from table name where id> 3 order by id asc limit 1 ";
The result is the same as what we thought. Finally, I will share a previously written function with you. the code is as follows:
The code is as follows :/*
Int $ tag 0
Int $ fid
*/
Function nextPre ($ tag = 0, $ zid, $ fid)
{
If ($ tag)
{
$ SQL = "Select field from table name where id <$ fid order by id desc limit 1 ";
}
Else
{
$ SQL = "Select field from table name where id> $ fid order by id asc limit 1 ";
}
// $ SQL = "Select * from table name where order by id desc limit 0, 10 ";
$ Result = mysql_query ($ SQL) or die ('query error ');
If (mysql_num_rows ($ result ))
{
$ Rs = mysql_fetch_array ($ result );
Return "". $ rs ['title']. "";
}
Else
{
Return 'no longer ';
}
}
Examples in this article describe how php gets an article. Share it with you for your reference. The specific method is as follows: I found a question on a station today...