Home > Backend Development > PHP Tutorial > php Chinese text data page turning (guestbook page turning)_PHP tutorial

php Chinese text data page turning (guestbook page turning)_PHP tutorial

WBOY
Release: 2016-07-21 16:07:54
Original
815 people have browsed it

There are many articles introducing page turning in mysq, but there are very few introductions to page turning in text data table format. Here I will briefly talk about page turning

Mainly introduce the following page turning ideas
1. Page turning of the guestbook
2. Page turning of the text forum

————————————————————————
Guestbook Page turning:
——————————————————————————————
This page turning in the text data table is The simplest page turning, please explain like this

golbal file
Data.dat --- NOTE FILE USE
user.dat --- Forum File use
Data.dat
_________________________________________________________________________
[1] [POSTUSER] [TITLE] [MEM] [POSTTIME] [IP]
[2] [POSTUSER] [TITLE] [MEM] [POSTTIME] [IP]
[3] [ POSTUSER] [TITLE] [MEM] [POSTTIME] [IP]
[4] [POSTUSER] [TITLE] [MEM] [POSTTIME] [IP]
[5] [POSTUSER] [TITLE] [MEM] [POSTTIME] [IP]

Note:
The [1,2,3,4,5....] were added by myself, mainly for everyone’s better understanding

index.php source:.

____________________________________________

---====BOF====---
$file = "data.dat"; "data file
if(file_exits($file)){ 🎜> fclose($fp);
unset($fp);
}
$listnumber = 20; //Number of items displayed per page
$fp = file ($file);             // Read data into the content
$number                                                                                                                                                                                                                                                                                       ){
print "No records yet, please leave a message";
/*+-------------------------------- ---+
|Print the FORM form here or connect to the form |
| URL, |
|
+------------------- -------------+*/
}else{
if(empty($_POST["page"])){ //This paragraph IF...ELSE.. .It was written to be compatible with the default settings of php4.20 and prevent invalid global variables.
                                                                                                                           🎜> }else{
$page = $_POST["page"]
}

if($page<0 || $page>pagenumber){ //Error detection processing, when the page parameter jumps out of the total page or is less than the home page (0), it will return to the first page
$page=0;
}

$startnote = $page*$listnumber; //Start recording position
$endnote =$startnote+$listnumber; //End recording position

//for($int_a=$startnote;$int_a<$endnote;$int_a++){ //The sorting display is similar to ASC mode

pirnt "

"

for($ int_a=$endnote;$int_a>=$startnote;$int_a--){ //Sorting is similar to DESC mode
To obtain the detailed data of each record, I used a TAB key to separate it
print "
User: $info[1] Title $info[2] Speech content: $info[3 ] Release time: $info[4] IP: $info[5]";
}

$prevpage = $page-1; //Number of PAGEs on the previous page
$nextpage = $page+1;                                                                                                                                                                                                                                                                          >Homepage
Previous page
Next page
Last page< /a>
                       < There may be 20 pages appearing.
Next page or
}
?>
---====EOF====---


Written in a hurry, and there are a lot of mistakes in the middle because of the consideration of using PHP4.20 So I changed it a bit, for example, PHP_SELF has adopted _SERVER["PHP_SELF"], etc.



http://www.bkjia.com/PHPjc/315039.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/315039.htmlTechArticleThere are many articles introducing page turning in mysq, but there are few introductions to page turning in text data table format. Here I will briefly talk about page turning and mainly introduce the following page turning ideas 1. Page turning of the guestbook 2....
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template