Jump to content

Any one can help if you know Files in PHP.. but i dont know . :( *SOLVED*


karthikeyan_coder

Recommended Posts

Hello,
    i am using flat file database...
the data format is
google.com || Google
msn.com || MSN
file name: data.txt

i need to delete a row if the id is first column...
let us say.. i need to delte the second row.. by clicking some link like.. deletelink.php?url=msn.com
$url = $_GET['url'];

now i need to delte the row which starts from $url from my text file... how is it possible? any help..  ???
[code]
<?php
$lines = file ('data.txt');

$fp = fopen('data.txt', 'w');

foreach ($lines as $line) {
    list ($url,$desc) = explode ('||', $line);
    if ($_GET['url']!= trim($url))
        fwrite ($fp, $line);
}

fclose ($fp);
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.