How to get the previous page and next page of an article in php
The example in this article describes how to obtain articles in php. Share it with everyone for your reference. The specific methods are as follows:
Today I found a problem with a website, which went directly to the latest article published on this channel. According to the principle, the ID before and after the article itself should be the upper and lower pages. Let me tell you in detail below.
Let’s look at an example first: 1,2,3,4,5.
If the above 5 are IDs, I want to use order by id asc to get the order, 4, well the principle is as simple as that.
SQL implementation method, 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 with you a function I wrote before. 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
}
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 more';
}
}
http://www.bkjia.com/PHPjc/941967.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/941967.htmlTechArticleHow to get the previous page and next page of the article in php. This article describes the method of getting the article in php. Share it with everyone for your reference. The specific method is as follows: Today I found a problem with a website...