HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Linking around a php file.
Post new topic   Reply to topic    HTML Help Forum -> PHP
View previous topic :: View next topic  
Author Message
oy



Joined: 20 Jun 2006
Posts: 71

PostPosted: Tue Dec 12, 2006 9:29 pm     Linking around a php file. Reply with quote

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:

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);
?>
Thor Erik



Joined: 30 Dec 2006
Posts: 8

PostPosted: Sat Dec 30, 2006 11:36 am     Reply with quote

Maybe try using php's Switch function?
http://no.php.net/manual/en/control-structures.switch.php
did't really understand what you ment, but from what i understood that may be the function your'e looking for Smile
oy



Joined: 20 Jun 2006
Posts: 71

PostPosted: Sat Dec 30, 2006 12:06 pm     Reply with quote

Oh, lol I kinda posted this awhile ago and have already figured out what I needed to do. But thanks for the response still atleast someone responded to it.
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial