Jason Wong,您好!

               Thank you,Mr. Jason Wong,I think what you said is below.If not,tell me 
the right way,ok?



=============================filename:edit.php=======(still have 
ERRORs)=================begin==>
<?  if (isset($_GET['action']) && $_GET['action'] == 'del' && !empty($_GET['id']))
  {
    $news=file("this.txt");
    $fp1 = fopen('outputfile', 'w');
    foreach ($news as $line) {
      if (strpos($line, $_GET['id']) !== 0)
         {
        fwrite($fp, $line);
         }
    }
    fclose($fp1);
   }

$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&id=$i'>DELETE THIS 
LINE</a></td></tr>";
if(($action==del)&&($id!==$i)){
             @fwrite($fp,$news[$i]);
                  }
    }
echo "</table>ok";
fclose($fp);?>
<====================================end


Is there any wrong above?Sorry,it do nothing again.
A friend told me to use "UNSET" and I'v got it,here's the source code of another way.
I'v got it from below source code,I'd like to share the code with you.
Although I'v got it,to study more knowledge--on the other hand,I still like to discuss 
your way to got it.


********************************************************************
=============filename:edit.php============(This way is OK!)====================>begin
<?$news=file('this.txt');
$num=count($news);
echo "<TABLE>";
for($i=0;$i<$num;$i++)
    {
    echo "<tr><td>".$news[$i]."</td><td><a 
href=myphpmail.php?action=del&line=$i>DELETE THIS LINE</a></td></tr>";
    }
echo "</table>ok";
if($action=='del')
{
unset($news[$line]);
$news=implode("",$news);
$fp=fopen('this.txt',"w");
            fputs($fp,$news);
} ?>
<====================================end

======= 2003-06-04 13:18:00 您在来信中写道:=======

>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

= = = = = = = = = = = = = = = = = = = =
                        

        致
礼!

                                
        poetbox
[EMAIL PROTECTED]
          2003-06-04




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to