search
Homephp教程php手册php中文本数据翻页(留言本翻页)_php基础

在mysq中介绍翻页的文章不少,而文本数据表格式的翻页介绍的很少,这里我就简单的说一下翻页

主要介绍以下翻页思想
1、留言本的翻页
2、文本论坛的翻页

————————————————————————
留言本的翻页:
——————————————————————————————
这个在文本数据表中的翻页是最简单的翻页,这样说明一下

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]

说明:
     其中的[1,2,3,4,5....]是我自己添加进去的,主要是为了大家更好的理解

index.php source:.

__________________________________________________

---====BOF====---

$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页出现        下一页    或
}
?>
---====EOF====---


写的仓促,另外中间有不少因为考虑到使用PHP4.20所以就改变了一下,比如说PHP_SELF已经采用_SERVER["PHP_SELF"]等
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment