On the view article details page, there is a link to the previous and next articles at the bottom. How do you implement this function? Generally, the document details are transmitted by passing the id in the past and reading the id record in the database. Therefore, id-1 or id + 1 cannot be used in the previous and next articles... on the view article details page,
At the bottom, there is a link to the previous and next articles,
How does one implement this function?
Generally, the details of an article are passed by an id,
Read this id record in the database,
The previous and next articles cannot be implemented using id-1 or id + 1,
Sometimes the Document id is not continuous, and a record will be deleted in some cases,
In this way, the id is not consecutive,
Therefore, the id-1 or id + 1 method is incorrect,
Do you have any other methods?
Reply content:
On the view article details page,
At the bottom, there is a link to the previous and next articles,
How does one implement this function?
Generally, the details of an article are passed by an id,
Read this id record in the database,
The previous and next articles cannot be implemented using id-1 or id + 1,
Sometimes the Document id is not continuous, and a record will be deleted in some cases,
In this way, the id is not consecutive,
Therefore, the id-1 or id + 1 method is incorrect,
Do you have any other methods?
$sql = '(select id,title from articles where id < :id order by id desc limit 1) union all (select id,title from articles where id > :id order by id asc limit 1)';
Mysql:select id from table where id>10 order by id desc limit 1