Shipwreck
06-26-2008, 12:17 PM
For the instructors section of shantiyoga.ca, there's an admin option to delete instructors. I've got it removing the information from the database, but I'm not sure of the best option for removing the images from the server.
This is what I have so far:
<?php if(isset($_POST['submit'])){
/// mySQL query
$query = "DELETE
FROM instructors
WHERE instructor_id = $postid";
mysql_query($query) or die (mysql_error());
if(mysql_affected_rows()==1){
header("Location: index.php?id=instructors");
}
}//submit
?>
I am hoping to delete the file based on the path i've been using to display the images:
($path_instructor_img is a variable I created in an include for the base url reference)
<?php echo "<img src=\"$path_instructor_img".$row['instructor_smallimg']."\"/>"; ?>
Would I delete the images from the server with an unlink statement like this:
('instructor_smallimg' is the file name)
unlink("$path_instructor_img".$row['instructor_smallimg'].");
As a new developer, my issues are always with proper syntax and code location. A push in the right direction would be greatly appreciated, I'm having trouble formatting this code properly.
This is what I have so far:
<?php if(isset($_POST['submit'])){
/// mySQL query
$query = "DELETE
FROM instructors
WHERE instructor_id = $postid";
mysql_query($query) or die (mysql_error());
if(mysql_affected_rows()==1){
header("Location: index.php?id=instructors");
}
}//submit
?>
I am hoping to delete the file based on the path i've been using to display the images:
($path_instructor_img is a variable I created in an include for the base url reference)
<?php echo "<img src=\"$path_instructor_img".$row['instructor_smallimg']."\"/>"; ?>
Would I delete the images from the server with an unlink statement like this:
('instructor_smallimg' is the file name)
unlink("$path_instructor_img".$row['instructor_smallimg'].");
As a new developer, my issues are always with proper syntax and code location. A push in the right direction would be greatly appreciated, I'm having trouble formatting this code properly.