Pages | data | Chinese in the MYSQ to introduce a lot of pages, and text data table-style page of the introduction of little, here I simply say the page
Mainly introduce the following page-flipping ideas
1, the page of the message book
2, the Text forum page
————————————————————————
The page of the message book:
——————————————————————————————
This page in the text datasheet is the easiest page to flip, which means
---====bof====---
?
$file = "Data.dat"; Data files
if (File_exits ($file)) {//fault tolerant processing to prevent the existence of no data files
$FP =fopen ($file, "w+");
Fclose ($FP);
Unset ($FP);
}
$listnumber = 20; Show number of bars per page
$fp = file ($file); reading data to content
$number = count ($fp); Calculate the total amount of data
$pagenumber = Floor ($number/$listnumber) +1;
if ($number <1) {
Print "Temporarily no record, welcome message";
/*+--------------------------------+
| print form form or connect to table here but |
| URL, |
+--------------------------------+*/
}else{
if (Empty ($_post["page")) {//This paragraph if ... ELSE ... is intended to be compatible with the default settings of php4.20 to prevent invalid global variables from being written
$page = 0; Because it is read from the data text, saved in the array, there is an O subscript
}else{
$page = $_post["page"]
}
if ($page <0 | | | $page >pagenumber) {//error handling, when page parameters jump out of the total page or less than the first page (0), will return to the top
$page = 0;
}
$startnote = $page * $listnumber; Start record position
$endnote = $startnote + $listnumber; End Record Location
For ($int _a= $startnote; $int _a< $endnote; $int _a++) {//Sort display like ASC mode
Pirnt "<table>"
For ($int _a= $endnote; $int _a>= $startnote; $int _a--) {//Sort displays similar desc mode
$info =explode ("T", $fp [$int-a]); Cutting data to obtain detailed data for each record I'm using a TAB key to split
Print <tr><td> users: $info [1] title $info[2] Content: $info [3] Published: $info [4] IP: $info [5];
}
$prevpage = $page-1; Page number of previous page
$nextpage = $page +1; Page number of the next page
Print "<tr><td>
<a href=\ "$_server[" php_self "]?page=0\" > Home </a>
<a href=\ "$_server[" php_self "]?page= $prevpage \" > Prev </a>
<a href=\ "$_server[" php_self "]?page= $nextpage \" > next page </a>
<a href=\ "$_server[" php_self "]?page= $pagenumber \" > End </a>
</table> "; Here you can add the page to the test directly here, that gives others to see is comfortable, but the effect is the same
For example: There may be 20 pages appearing <a href= "index.php?page=21" > next page </a> or <a href= "Index.php?page=-1" >
}
?>
---====eof====---
Write a hasty, the other in the middle there are many because of the use of PHP4.20 so that the change, for example, Php_self has adopted _server["php_self", and so on, the detailed reference to the essence of the Chinese instructions to see the name of the
The above for the text of the message to save the page function of this data, specific to the text of the Forum page to consider more detailed points, if the time to and, I will write out as soon as possible ....
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.