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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.