Ok this is probably a really stupid question but I am asking it couldn't find anything about it using google probably cause I was searching the wrong thing.
I am trying to use a link in html to link to another part of a php file. I have a script displaying a directory and using looping to show the pages in the directory but I am trying to have it where when the press a image link in that loop it goes to another part of that script that contains another web page which carry's out the delete.
Here is an example of my code:
I know there is probably some syntax errors in that. But thats what I am trying to do I am trying to link !!Delete!! in the link in the loop to the !!Delete!! part of the script.
Also if there is a way of putting the php script right in the link I would rathe r do that like this:
I am trying to use a link in html to link to another part of a php file. I have a script displaying a directory and using looping to show the pages in the directory but I am trying to have it where when the press a image link in that loop it goes to another part of that script that contains another web page which carry's out the delete.
Here is an example of my code:
| Code: |
|
<?php // path to the folder listed - can be full path //$path = "/var/www/html/"; //or relative path $path = "./"; // Open the folder for display $dir_handle = @opendir($path) or die("Unable to open $path"); // Loop through the files while (false !== ($file = readdir($dir_handle))) { // do not display current file if($file == "opendir.php") continue; if($file == "FCKeditor") continue; if($file == "userdata") continue; if($file == "images") continue; if($file == ".") continue; if($file == "..") continue; // Display file links echo "<table border=\"0\" width=\"100%\">"; echo "<tr><td><a href=\"$file\"><img src=\"images/file.PNG\" border=\"0\"></a> <a href=\"$file\">$file</a></td><td width=\"16\" height=\"16\"><img src=\"images/view.PNG\" border=\"0\"></td><td width=\"16\" height=\"16\"><img src=\"images/edit.PNG\" border=\"0\"></td><td width=\"16\" height=\"16\"><a href=\"!!Delete!!\"><img src=\"images/delete.PNG\" border=\"0\"></a></td></tr>"; echo "</table>"; } // Close directory closedir($dir_handle); !!Delete!! unlink($file); echo "<html><body>File Succesfully Deleted</body></html>" else echo "<html><body>Unable To Delete File</body></htm>" ?> |
I know there is probably some syntax errors in that. But thats what I am trying to do I am trying to link !!Delete!! in the link in the loop to the !!Delete!! part of the script.
Also if there is a way of putting the php script right in the link I would rathe r do that like this:
| Code: |
| <?php
// path to the folder listed - can be full path //$path = "/var/www/html/"; //or relative path $path = "./"; // Open the folder for display $dir_handle = @opendir($path) or die("Unable to open $path"); // Loop through the files while (false !== ($file = readdir($dir_handle))) { // do not display current file if($file == "opendir.php") continue; if($file == "FCKeditor") continue; if($file == "userdata") continue; if($file == "images") continue; if($file == ".") continue; if($file == "..") continue; // Display file links echo "<table border=\"0\" width=\"100%\">"; echo "<tr><td><a href=\"$file\"><img src=\"images/file.PNG\" border=\"0\"></a> <a href=\"$file\">$file</a></td><td width=\"16\" height=\"16\"><img src=\"images/view.PNG\" border=\"0\"></td><td width=\"16\" height=\"16\"><img src=\"images/edit.PNG\" border=\"0\"></td><td width=\"16\" height=\"16\"><a href=\"unlink($file)\"><img src=\"images/delete.PNG\" border=\"0\"></a></td></tr>"; echo "</table>"; } // Close directory closedir($dir_handle); ?> |
