Jump to content

Deleting images from server if dB row is deleted..?


DBookatay

Recommended Posts

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);}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.