timmah1 Posted December 13, 2007 Share Posted December 13, 2007 I'm trying to switch default images. The database has a field name "main", the default is set to '0', when it is the default image, it gets set to '1'. If I want to switch one photo for the other, how would I change the photo's id to reflect this change at the same time? Example: name main top.jpg 0 bottom.jpg 1 But I want to make top '1' and bottom '0'. How is this done at the same time? I hope I worded this correctly and you understand. Thanks for your help in advance. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 13, 2007 Share Posted December 13, 2007 carry across the id number of the pic to be come the new "default" then do something like <?php $id = 2; //connect sql $q = "Update `Default_Images` Set `Default` = '0'"; $r = mysql_query($q) or die(mysql_error()); $q = "Update `Default_Images` Set `Default` = '1' where ImageID = '".$id."'"; $r = mysql_query($q) or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 13, 2007 Author Share Posted December 13, 2007 perfect! thank you very much Quote Link to comment 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.