Tianshui Online Mayor Message Board Using text files to create message board prompts (Part 2)

WBOY
Release: 2016-07-29 08:33:32
Original
3517 people have browsed it

Managing your messages in a text file is not as convenient as in a database. Let's find a way to achieve this effect!
When outputting, we use arrays to save data, so we can easily assign a serial number to each set of data in order. By operating on this serial number, we can easily modify the data!
$date[0] is the first line in the text file, and the serial number is 0 when we output it.
The output has this effect:
Modify message< ;/a>
Let’s customize modify.php
if($id!=””){
$date=file(“txt/mytxt.txt”);
$str=explode(“& ",$date[0])
?>


>
>
< ;input type="text" name="tech3" value=>

}else{
$str=$tech1.”&”. $tech2. ”&”.$tech3….
If($str!=””){
//Write the modified data back to the text file!
}
}?>
In this process, pay attention to keep the value of $id from being lost. When writing back the data, first read the value in the text into $date, and then $date[$id]=$str;
$fp=fopen("txt/mytxt.txt","w");
fwrite($fp,$date);
fclose($fp);

The above introduces the Tianshui Online Mayor Message Board Tips for using text files to create a message board (Part 2), including the content of the Tianshui Online Mayor Message Board. I hope it will be helpful to friends who are interested in PHP tutorials.

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!