PHP implements the code of the previous and next articles. Code :? Php ---- show the code of the previous and next articles START ---- $ SQL _formerselect * fromarticlewhereid $ idorderbyiddesc; SQL statement of the previous article. Note that it is in reverse order, because
Code:
- // ---- 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
";}
- // Www.jbxue.com
- $ 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
";}
- ?>
Why :? Php // ---- show the code of the previous and next articles START ---- $ SQL _former = "select * fromarticlewhereid $ idorderbyiddesc"; // the SQL statement of the previous article. Note that it is in reverse order, because...