On Wednesday 04 June 2003 08:36, poetbox wrote: > As you know,I'm a newbie in PHP,I tried your way last night,but to my > surprise,it do nothing for any way,it didn't delete any line in the > TXT-file,even the file "outputfile.txt" indeed! Perhaps it because that I > haven't understand your thought and absolutely copy your words to the > program,but,can you give me more help? After I write "del.php" copy your > words,I'v been trying to edit my manage file "edit.php" as follow:
The code that I gave should be in a separate file (del.php) and should NOT be incorporated into edit.php as you have tried to do below. > ---filename:edit.php------------> > <? > $news=file('this.txt'); > $num=count($news); > $fp=fopen('outputfile','w'); > echo "<TABLE>"; > for($i=0;$i<$num;$i++){ > echo "<tr><td>".$news[$i]."</td><td><a > href=edit.php?action=del>删除此行</a></td></tr>"; > if($action!='del')[EMAIL PROTECTED]($fp,$news[$i]); > } > echo "</table>ok"; > fclose($fp);?> > <-------------------------------- If you want to combine the functionality of edit.php and del.php into a single page then the easiest way is to place this code at the beginning: if (isset($_GET['action']) && $_GET['action'] == 'del' && !empty($_GET['id'])) { $news=file("this.txt"); $fp = fopen('outputfile', 'w'); foreach ($news as $line) { if (strpos($line, $_GET['id']) !== 0) { fwrite($fp, $line); } } fclose($fp); } Then follow it with your original edit.php, BUT replace this link: <a href=del.php>DELETE THIS LINE</a> with <a href="edit.php?action=del&id=$id">DELETE THIS LINE</a> -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Billy: Mom, you know that vase you said was handed down from generation to generation? Mom: Yes? Billy: Well, this generation dropped it. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php