Do look at the right looks like forgot to write this, hehe, oh by the way write again
Many friends use DAT files to store small volumes of data, build text data table use, many and I belong to the bird class friend although to how to append, delete files, empty files are very familiar with, but for a file within the operation of a record is helpless, recently wrote a small message book, to achieve this function, So let's talk about it.
_________________________________________________________
This file is the file that holds the data
[1]-------------represent record data
The-------------represents the split symbol for a data table and can be a \r,\n character
Read Page read.php
(Content slightly)
Arrange the data in the Data.dat to display. As follows
1, you dora---(sports98) 2002-13-42-(checkbox)
2, you dora---(sports98) 2002-13-42-(checkbox)
3, you dora---(sports98) 2002-13-42-(checkbox)
4, you dora---(sports98) 2002-13-42-(checkbox)
Pass the checkbox information through the form
do.php
do.php contents are as follows:
$filename = "Data.dat";//Data file
$FP =file ($filename);//Read the data file into
$number =count ($FP);//Calculate total amount of data
for ($int _a=0; $int _a< $number; $int _a++) {
if ($int _a== $checkbox [])//here can be one or multiple judgments, here is to delete a record as an example
Continue
Else
$newmem. = $fp [$int _a]. " \ r "; Assigning the contents of a file to a new value
}
$WFP =fopen ($filename, "w");
Fputs ($WFP, $newmen);
Fclose ($WFP);
The idea of deletion is to read the data in the text into memory, after the operation in memory and then empty the file to write, the records that meet the deletion criteria can be deleted,
The editor is to replace the records that match the conditions can be pulled ~
$filename = "Data.dat";//Data file
$FP =file ($filename);//Read the data file into
$number =count ($FP);//Calculate total amount of data
for ($int _a=0; $int _a< $number; $int _a++) {
if ($int _a== $checkbox [])//here can be one or multiple judgments, here's to edit a record for example
$newmem. = "";//here is the modified content
Else
$newmem. = $fp [$int _a]. " \ r "; Assigning the contents of a file to a new value
}
$WFP =fopen ($filename, "w");
Fputs ($WFP, $newmen);
Fclose ($WFP);
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