fri3ndly Posted February 5, 2008 Share Posted February 5, 2008 I am trying to make a 'delete image' button that will remove the thumbnail and image ONLy from a table containing property information and images. How do i delete only from 2 columns of the table? Is this right? Only it deleted the whole property! $remove_image_query = mysql_query("DELETE FROM properties WHERE property_id='$prop_id' AND photo_thumb='$photo_thumb' AND photo_standard='$photo_standard'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/89548-solved-simple-php-mysql-problem/ Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 That will delete the whole row from the table. If you want to delete a couple fields from a table, just set those columns to null using UPDATE. Quote Link to comment https://forums.phpfreaks.com/topic/89548-solved-simple-php-mysql-problem/#findComment-458694 Share on other sites More sharing options...
fri3ndly Posted February 5, 2008 Author Share Posted February 5, 2008 Lol, I didnt even think of that. Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/89548-solved-simple-php-mysql-problem/#findComment-458696 Share on other sites More sharing options...
fri3ndly Posted February 5, 2008 Author Share Posted February 5, 2008 So is this right? Not changing the fields to a blank but just leaving them as they are: $remove_image_query = mysql_query("UPDATE properties SET photo_thumb='', photo_standard='' WHERE property_id='$prop_id'")or die(mysql_error()); if ($remove_image_query){ echo "Image deleted and removed from database."; } Quote Link to comment https://forums.phpfreaks.com/topic/89548-solved-simple-php-mysql-problem/#findComment-458716 Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 That will work, but I prefer NULL myself. (ex SET photo_thumb='NULL') Quote Link to comment https://forums.phpfreaks.com/topic/89548-solved-simple-php-mysql-problem/#findComment-458727 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.