Jump to content

[SOLVED] delete images names from database


Recommended Posts

hi all

 

i want to remove the uploaded images and thumb names from my product table in database.

 

but its not deleting.

 

This is the checkbox in from

<input type="checkbox" name="rem" id="rem" /> 

 

This is the delete qry

if(isset($_REQUEST['rem']))
{
$qry_rm="delete '$oldpic2', '$oldthumb2' from product_table where product_id=$id";
echo $qry_rm;
$result_rm=mysql_query($qry_rm);
}

 

on echoing the qry i get the correct output the images are not deleting.

delete 'htc_t8282_flip2.jpg', 'htc_t8282_flip2.jpg' from product_table where product_id=199

 

 

vineet

 

Hi,

can't quite work out how yhour code is working but anyway, to remove specific field data from a table row, you should use ALTER.

Are these images in one row or seperate rows?

 

If they are image fields in one row where product_id is unique:

ALTER product_table SET image_field_1='', image_field_2='' WHERE product_id=199

If they are seperate rows but there is other data that you don't want to delete:

ALTER product_table SET image_field='' WHERE product_id=199 AND image_field='htc_t8282_flip2.jpg'

If you only have a product_id field and image field you can remove the whole row:

DELETE FROM product_table WHERE product_id=199 AND image_field='htc_t8282_flip2.jpg' LIMIT 1

Depending on what you have, one of those should work :)

 

A bit more info about your product_table structure would be useful to give a more exact answer.

 

Chris

hi cbolson

 

thanks for the reply.

 

your provided solution worked for me. its now deleting the images fine as required.

 

thanks

 

vineet

 

 

Hi,

can't quite work out how yhour code is working but anyway, to remove specific field data from a table row, you should use ALTER.

Are these images in one row or seperate rows?

 

If they are image fields in one row where product_id is unique:

ALTER product_table SET image_field_1='', image_field_2='' WHERE product_id=199

If they are seperate rows but there is other data that you don't want to delete:

ALTER product_table SET image_field='' WHERE product_id=199 AND image_field='htc_t8282_flip2.jpg'

If you only have a product_id field and image field you can remove the whole row:

DELETE FROM product_table WHERE product_id=199 AND image_field='htc_t8282_flip2.jpg' LIMIT 1

Depending on what you have, one of those should work :)

 

A bit more info about your product_table structure would be useful to give a more exact answer.

 

Chris

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.