Free message The page code of the text message

Source: Internet
Author: User
Use "| | |" When writing a file To separate each record, "| |" Used to separate fields in a record
If a record is represented as $str 1= $name. "| |". $pass. "| |". $title. "| |". $message. "| |". .........
Then connect record one and record two o'clock with, $str = $str 1. "| | |". $str 2. "| | | .........
The last file generated is as follows
Flying Fox | | 450948643| | This is the theme | | This is the message content | | 1| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 2| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 3| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 4| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 5| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 6| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 7| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | |8| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 9| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 10| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 11| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 12| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 13| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 14| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 15| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 16| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 17| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 18| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 19| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 20| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 21| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 22| | | Flying Fox | | 450948643| | This is the theme | | This is the message content | | 23| | |
Then start fetching the data in the file, the program list is as follows
$end = "| | |"; Record delimiter, depending on the symbol used when writing the file
$mid = "| |"; Field delimiter, Ibid.
$temp =file ("Messageboard.info"); Read the contents of a file into an array
$temp =join ("", $temp); Turn the read-out array into a string
$mess =explode ($end, $temp); Split a record
$num =count ($mess); Calculates the number of elements in a segmented array of strings, that is, the number of records
if (! $dpage) $dpage = 1; Hold current page
$row = 15; The number of rows you want to display per page
if ($num/$row ==floor ($num/$row)) $page = $num/$row; See if you can get an integer, you can take the whole
else if ($num/$row >=floor ($num/$row)) $page =floor ($num/$row) +1; If the total number of rows per page is greater than the number of things to take, add one after the whole.
else if ($num/$row <=floor ($num/$row)) $page =floor ($num/$row); If it is smaller than the rounding, take the whole
$minnum = ($dpage-1) * $ROW; The current page starts the record from this number
$maxnum = $row * $dpage; Maximum number of records to fetch for the current page
for ($i = $minnum; $i < $maxnum; $i + +)
{
$message =explode ($mid, $mess [$i]); To split a field in a record
$num 1=count ($message); Calculates the number of elements in an array for controlling loops
for ($j =0; $j < $num 1; $j + +)
{
echo $message [$j]. " "; Each time an element in an array is displayed.
}
echo "
";
}
Start paging below
if ($page >=2&& $dpage ==1)//If the total number of pages is greater than two pages and is currently on the first page
{$paged = $dpage +1; echo "previous page next page
"; }
else if ($page >=2&& $dpage >= $page)//If the total number of pages is greater than two pages and the current page is less than the total number of pages
{$pageu = $dpage-1; Echo "previous page next page
"; }
else if ($page >=2&& $dpage >=1&& $dpage < $page)//If the total number of pages is greater than two pages and the current page is greater than one and less than the total number of pages
{$pageu = $dpage-1; $paged = $dpage +1;echo "Previous page previous page
";}
If there is only one page
else echo "Previous page previous page
";
?>
"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"

The above introduction of the free message of the text of the message of the page code, including the content of the free message, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.