关于文本留言本的分页代码_PHP
//在写文件的时候用"|||"来分离每条记录,"||"用来分离记录中的各个字段
//如记录一表示为 $str1=$name."||".$pass."||".$title."||".$message."||".………
//然后连接记录一和记录二时用,$str=$str1."|||".$str2."|||.………
//最后生成的文件如下
//飞天狐狸||450948643||这是主题||这是留言内容||1|||飞天狐狸||450948643||这是主题||这是留言内容||2|||飞天狐狸||450948643||这是主题||这是留言内容||3|||飞天狐狸||450948643||这是主题||这是留言内容||4|||飞天狐狸||450948643||这是主题||这是留言内容||5|||飞天狐狸||450948643||这是主题||这是留言内容||6|||飞天狐狸||450948643||这是主题||这是留言内容||7|||飞天狐狸||450948643||这是主题||这是留言内容||8|||飞天狐狸||450948643||这是主题||这是留言内容||9|||飞天狐狸||450948643||这是主题||这是留言内容||10|||飞天狐狸||450948643||这是主题||这是留言内容||11|||飞天狐狸||450948643||这是主题||这是留言内容||12|||飞天狐狸||450948643||这是主题||这是留言内容||13|||飞天狐狸||450948643||这是主题||这是留言内容||14|||飞天狐狸||450948643||这是主题||这是留言内容||15|||飞天狐狸||450948643||这是主题||这是留言内容||16|||飞天狐狸||450948643||这是主题||这是留言内容||17|||飞天狐狸||450948643||这是主题||这是留言内容||18|||飞天狐狸||450948643||这是主题||这是留言内容||19|||飞天狐狸||450948643||这是主题||这是留言内容||20|||飞天狐狸||450948643||这是主题||这是留言内容||21|||飞天狐狸||450948643||这是主题||这是留言内容||22|||飞天狐狸||450948643||这是主题||这是留言内容||23|||
//然后就开始取文件中的数据,程序清单如下
$end="|||"; //记录分隔符,视写文件时用的符号定
$mid="||"; //字段分隔符,同上
$temp=file("messageboard.info"); //把文件内容读入数组
$temp=join("",$temp); //将读出的数组变成字串
$mess=explode($end,$temp); //分割出记录
$num=count($mess); //计算分割出的字串数组元素数量,就是记录数
if (!$dpage) $dpage=1; //存放当前页数
$row=15; //你每页想显示的行数
if ($num/$row==floor($num/$row)) $page=$num/$row; //看是否能得整数,可以就取整
else if ($num/$row>=floor($num/$row)) $page=floor($num/$row) 1; //如果总数除每页行娄比取事数大,就取整后加一。
else if ($num/$row $minnum=($dpage-1)*$row; //当前页从此数开始取记录
$maxnum=$row*$dpage; //当前页要取的最大记录数
for($i=$minnum;$i {
$message=explode($mid,$mess[$i]); //分割出记录中的字段
$num1=count($message); //计算数组中元素的数量用于控制循环
for ($j=0;$j {
echo $message[$j]." "; //每次显示数组内的一个元素。
}
echo "
";
}
//下面开始分页
if ($page>=2&&$dpage==1) //如果总页数大于两页,并且当前在第一页的话
{ $paged=$dpage 1; echo "上一页 下一页
"; }
else if ($page>=2&&$dpage>=$page) //如果总页数大于两页,并且当前页小于总页数
{ $pageu=$dpage-1; echo "上一页 下一页
"; }
else if ($page>=2&&$dpage>=1&&$dpage { $pageu=$dpage-1;$paged=$dpage 1;echo "上一页 上一页
";}
//如果只有一页
else echo "上一页 上一页
";
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart

How to change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

The win10 system is a very excellent high-intelligence system. Its powerful intelligence can bring the best user experience to users. Under normal circumstances, users’ win10 system computers will not have any problems! However, it is inevitable that various faults will occur in excellent computers. Recently, friends have been reporting that their win10 systems have encountered frequent blue screens! Today, the editor will bring you solutions to different codes that cause frequent blue screens in Windows 10 computers. Let’s take a look. Solutions to frequent computer blue screens with different codes each time: causes of various fault codes and solution suggestions 1. Cause of 0×000000116 fault: It should be that the graphics card driver is incompatible. Solution: It is recommended to replace the original manufacturer's driver. 2,

Termination Code 0xc000007b While using your computer, you sometimes encounter various problems and error codes. Among them, the termination code is the most disturbing, especially the termination code 0xc000007b. This code indicates that an application cannot start properly, causing inconvenience to the user. First, let’s understand the meaning of termination code 0xc000007b. This code is a Windows operating system error code that usually occurs when a 32-bit application tries to run on a 64-bit operating system. It means it should

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

What does the 0x000000d1 blue screen code mean? In recent years, with the popularization of computers and the rapid development of the Internet, the stability and security issues of the operating system have become increasingly prominent. A common problem is blue screen errors, code 0x000000d1 is one of them. A blue screen error, or "Blue Screen of Death," is a condition that occurs when a computer experiences a severe system failure. When the system cannot recover from the error, the Windows operating system displays a blue screen with the error code on the screen. These error codes

Quickly get started with Python drawing: code example for drawing Bingdundun Python is an easy-to-learn and powerful programming language. By using Python's drawing library, we can easily realize various drawing needs. In this article, we will use Python's drawing library matplotlib to draw a simple graph of ice. Bingdundun is a cute panda who is very popular among children. First, we need to install the matplotlib library. You can do this by running in the terminal

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button
