Hi!
I have a problem with the unlink() php function. What I try to do is to delete a certain file in a directory. Now the function works fine. But when I call it then it deletes ALL the files inside of that directory. What I want is for it to delete that certain file which the user can select from a list.
I display all the files with php and beside it is a 'X' ahref link which doesn't seem to be identified with that file next to it. This 'X' is used to delete the file.
echo "$file <a title='Delete book' href='#' onclick=".delete($file).">X</a>";
This line prints all the files listed in the directory. (It's in a while loop)
Here is the delete function:
function delete($var){
$link = './book/'.$var;
unlink($link);
}
I'm not sure how to identify the 'X' with the book next to it. Because at the moment it seems 'X' is linked to all the files.
Any help will be appreciated!
Thanks!