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. Link to comment https://forums.phpfreaks.com/topic/81530-solved-change-deafult-image/ 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()); ?> Link to comment https://forums.phpfreaks.com/topic/81530-solved-change-deafult-image/#findComment-413964 Share on other sites More sharing options...
timmah1 Posted December 13, 2007 Author Share Posted December 13, 2007 perfect! thank you very much Link to comment https://forums.phpfreaks.com/topic/81530-solved-change-deafult-image/#findComment-413981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.