Home > Backend Development > PHP Tutorial > php txt message board (also has paging function)_PHP tutorial

php txt message board (also has paging function)_PHP tutorial

WBOY
Release: 2016-07-20 11:08:36
Original
1346 people have browsed it

php txt message board (also has paging function)

php tutorial txt message board (also has paging function)

$ file = "data.dat"; // data file
if (file_exits ($ file)) {// fault tolerance processing, prevent the existence of unsecured files
$ fp = FOPEN ($ file, "" "" "" "" "" "" "" "" w+");
fclose($fp);
unset($fp);
}
$listnumber = 20; //Number of items displayed per page
$fp = file($ file); // Read data to
$ Number = Count ($ FP); // Calculate the total data volume
$ Pagenumber = Floor ($ Number/$ ListNumber) +1; ($number<1){
print "No record yet, please leave a message";
/*+------------------------ --------+
|Print the form here or connect to the table |
| url, |
|
+------------- ------------------+*/
}else{
if(empty($_post["page"])){ //This if. ..else... is written to be compatible with the default settings of php4.20 and to prevent invalid global variables
                                                                                     o subscript
}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 homepage (0), it will return to the first page
          $page=0;
$endnote = $startnote+$listnumber; //End recording position
//for($int_a=$startnote;$int_a<$endnote;$int_a++){ //Sort display similar to asc mode
pirnt ""
for($int_a=$endnote;$int_a>=$startnote;$int_a--){ //The sorting display is similar to desc mode
$info=explode("t",$ fp[$int-a]); //Cut the data to get the detailed data of each record. I used a tab key to split it
print "
User:$info[1] Title $info[2] Speech content: $info[3] Release time: $info[4] ip:$info[5]";
}
$prevpage = $page-1; //Previous page The number of pages
$nextpage = $page+1; //The number of pages on the next page
print "

Homepage
Previous page
< ;a href="$_server["php_self"]?page=$nextpage">Next page
Last page
& lt;/table & gt; "; // Here you can directly add the test detection here, so it is comfortable to show others, but the effect is the same
// for example: here there may be 20 pages here & lt ;a href="index.php?page=21">Next page Or


}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444868.htmlTechArticlephp txt message board (also has paging function) php tutorial txt message board (also has paging function) $file = data. dat; //Data file if(file_exits($file)){ //Fault tolerance processing to prevent the existence of no data files...
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