DBookatay Posted February 24, 2008 Share Posted February 24, 2008 I have a query (if a vehicle in inventory gets sold) the when it runs it takes a few items from one table ("Inventory") and moves them to a different table ("Sold") and then deletes the row in "Inventory". In my "Inventory" table there are 10 fields: "pic1" - "pic10" which none are required, but more so than not are all usually used, meaning there are 10 pictures of the vehicle. I use an image upload script that uploads the images, places them in a folder, creates a thumbnail in a seperate thumbnail folder, and adds the name of the image to the proper field. Is there a way to now reverse the process? Meaning that if I run my query (code below) and mark the vehicle sold, if any of the 10 fileds has a listing in it, it will delete the actual image from the folder? Can this easily be done? Here is the 2 queries to mark a vehicle sold: if (isset($_POST['sold'])) { $insertQuery = mysql_query("INSERT INTO Sold (stock, vin, year, make, model, trim, body, color, mileage) VALUES ('$stock', '$veh_VIN', '$veh_Year', '$veh_Mke', '$veh_Mdl', '$veh_Trm', '$veh_Bdy', '$veh_color', '$veh_Mls')") or die(mysql_error()); echo "<meta http-equiv=\"Refresh\" content=\"0; url=list.php?category=001\">";} // Delete Vehicle (When Marked Sold) if ($insertQuery) {$query = "DELETE FROM Inventory where stock = '{$_POST['stock']}'"; $result = mysql_query($query);} Link to comment https://forums.phpfreaks.com/topic/92743-deleting-images-from-server-if-db-row-is-deleted/ Share on other sites More sharing options...
themistral Posted February 24, 2008 Share Posted February 24, 2008 Have a look at the unlink function. http://uk.php.net/unlink Link to comment https://forums.phpfreaks.com/topic/92743-deleting-images-from-server-if-db-row-is-deleted/#findComment-475164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.