Use PHP to implement the code of the previous and next articles. Copy the code as follows :? Php ---- show the code of the previous and next articles START ---- $ SQL _formerselect * fromarticlewhereid $ idorderbyiddesc; SQL statement of the previous article
The code is as follows:
// ---- Display the code START in the previous and next articles ----
$ SQL _former = "select * from article where id <$ id order by id desc"; // the SQL statement of the previous article. Note that it is inverted because only the first article is used when the result set is returned, instead of the last article.
$ SQL _later = "select * from article where id> $ id"; // the SQL statement in the next article
$ Queryset_former = mysql_query ($ SQL _former); // execute an SQL statement
If (mysql_num_rows ($ queryset_former) {// returns the number of records and determines whether it is true. Based on this, the result is displayed.
$ Result = mysql_fetch_array ($ queryset_former );
Echo "previous". $ result [title]."
";
} Else {echo "no more in the previous article
";}
$ Queryset_later = mysql_query ($ SQL _later );
If (mysql_num_rows ($ queryset_later )){
$ Result = mysql_fetch_array ($ queryset_later );
Echo "next". $ result ['title']."
";
} Else {echo "the next article is missing
";}
?>
The http://www.bkjia.com/PHPjc/326111.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/326111.htmlTechArticle code is as follows :? Php // ---- show the code of the previous and next articles START ---- $ SQL _former = "select * from article where id $ id order by id desc"; // the SQL statement of the previous article...