Phptxt message board (paging function ). Phptxt message board (paging function) php Tutorial txt message board (paging function) $ filedata. dat; data file if (file_exits ($ file) {fault tolerance processing to prevent the absence of data files from having php txt message board (paging function)
Php Tutorial txt message board (paging function)
$ File = "data. dat"; // data file
If (file_exits ($ file) {// fault tolerance processing to prevent the existence of non-data files
$ Fp = fopen ($ file, "w + ");
Fclose ($ fp );
Unset ($ fp );
}
$ Listnumber = 20; // Number of Entries displayed per page
$ Fp = file ($ file); // read data to the content
$ Number = count ($ fp); // calculates the total data volume
$ Pagenumber = floor ($ number/$ listnumber) + 1;
If ($ number <1 ){
Print "no record at the moment, please leave a message ";
/* + -------------------------------- +
| Print the form or link to the table here |
| Url, |
+ -------------------------------- + */
} Else {
If (empty ($ _ post ["page"]) {// this section if... else... it is written to ensure compatibility with the default php4.20 settings and prevent invalid global variables.
$ Page = 0; // because it is read from the data text, it is saved in the array and has an o subscript.
} Else {
$ Page = $ _ post ["page"]
}
If ($ page <0 | $ page> pagenumber) {// when the page parameter jumps out of the total page or is smaller than the homepage (0), it is returned to the first page.
$ Page = 0;
}
$ Startnote = $ page * $ listnumber; // start recording location
$ Endnote = $ startnote + $ listnumber; // end record location
// For ($ int_a = $ startnote; $ int_a <$ endnote; $ int_a ++) {// sorting display is similar to asc mode
Pirnt"
"For ($ int_a = $ endnote; $ int_a >=$ startnote; $ int_a --) {// sort display is similar to desc mode$ Info = explode ("t", $ fp [$ int-a]); // cut data to obtain detailed data for each record. here we use a tab key to separatePrint"
User: $ info [1] Title $ info [2]: $ info [3] Release date: $ info [4] ip: $ info [5] ";
}
$ Prevpage = $ page-1; // Number of pages on the previous page
$ Nextpage = $ page + 1; // Number of pages on the next page
Print" |
Homepage
Previous Page
Next page
Last page
|
"; // You can directly add the page detection here, so that it is comfortable for others, but the effect is the same
// For example, the next page or
}
Http://www.bkjia.com/PHPjc/444868.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444868.htmlTechArticlephp txt message board (also paging function) php Tutorial txt message board (also paging function) $ file = data. dat; // data file if (file_exits ($ file) {// fault tolerance processing to prevent the existence of non-data files...