php txt留言板(还分页功能)_PHP教程

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

php txt留言板(还分页功能)

php教程 txt留言板(还分页功能)

$file            =        "data.dat";        //数据文件
if(file_exits($file)){                        //容错处理,防止无数据文件存在
    $fp=fopen($file,"w+");
    fclose($fp);
    unset($fp);
}
$listnumber        =        20;            //每页显示条数
$fp            =        file($file);        //读取数据到内容中
$number            =        count($fp);        //计算总数据量
$pagenumber        =        floor($number/$listnumber)+1;
if($number    print "暂时无记录,欢迎留言";
    /*+--------------------------------+
          |在这里打印form表单或连接到表但的|
          | url,               |
          +--------------------------------+*/
}else{
    if(empty($_post["page"])){                //这段if...else...是为了兼容php4.20的默认设置,防止出现无效的全局变量而写的
        $page        =    0;            //因为是从数据文本读出来的,保存在数组中,有个o下标
    }else{
        $page        =    $_post["page"]
    }
    if($pagepagenumber){            //检错处理,当页面参数跳出总页面或小于首页(0)的时候,将返回到第一页
        $page=0;
    }
    $startnote    =    $page*$listnumber;        //开始记录位置
    $endnote    =    $startnote+$listnumber;        //结束记录位置
    //for($int_a=$startnote;$int_a    pirnt ""
    for($int_a=$endnote;$int_a>=$startnote;$int_a--){    //排序显示类似desc模式
        $info=explode("t",$fp[$int-a]);        //切割数据获得每条记录的详细数据我这里是用了一个tab键分割
        print "
用户:$info[1] 标题$info[2] 发言内容:$info[3] 发布时间:$info[4] ip:$info[5]";
    }
    $prevpage    =    $page-1;            //上一页的page数
    $nextpage    =    $page+1;            //下一页的page数
    print "

    首页
    上一页
    下一页
    尾页
   
";                        //这里您可以直接将页面的检测加到这里,那样给别人看的是舒服的,但是效果是一样的
                                //例如:这里有可能出现20页出现        下一页    或


}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444868.htmlTechArticlephp txt留言板(还分页功能) php教程 txt留言板(还分页功能) $file = data.dat; //数据文件 if(file_exits($file)){ //容错处理,防止无数据文件存在...
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!