Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete a particular file by using PHP

Status
Not open for further replies.

newlearner2005

Programmer
May 9, 2005
32
0
0
US
Hello everybody,

Could anybody show me how to delete a particular file by using PHP ? ( not in MySQL prompt)
On the webpage I design look like this
test1.doc [DELETE]
test2.txt [DELETE]
test3.jpg [DELETE]
...
...
Assume (I want to delete test2.txt) I click on [DELETE] on the coresponding line of test2.txt
Then it will be deleted ( It will show the same page but I did not see text2.txt anymore)
I created a database with id column as primary key to recognize a particular file. But when I delete test2.txt or any file, no matter what, it always deletes the first file on line 1 ( in this case test1.doc )

Thank you very much for your help

new learner
 
unlink('/path/to/file');

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thank you very much for your help, KarveR
But those files are in a table in MySQL database. They are not in the directory (folder). So they do not have /path/bla bla bla/...

new learner 2005
 
Ah I see, must read more and post less :)

What code are you using at the moment, I gues sit would be helpful if you posted that.

The sql statement should read something along the lines of:

$sql="delete from table where id='2'";

To be able to see your code would make this much much easier.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thank you very much, KarveR

Base on your guide:
$sql="delete from table where id='2'";

I got it now.
This is also the important line below I really need. You must knew that before, but I do not
$id = $_REQUEST['id'];

Thank you so much again.
new learner 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top