vinpkl Posted September 11, 2009 Share Posted September 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/173876-solved-delete-images-names-from-database/ Share on other sites More sharing options...
cbolson Posted September 11, 2009 Share Posted September 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/173876-solved-delete-images-names-from-database/#findComment-916583 Share on other sites More sharing options...
vinpkl Posted September 11, 2009 Author Share Posted September 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/173876-solved-delete-images-names-from-database/#findComment-916586 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.