praethorian Posted March 7, 2009 Share Posted March 7, 2009 Hi all, I have a classic edit.php file, with 8 file fields (named fname1 - fname8). User already uploaded pictures and he decided to change some of them. This is sql query that update all columns in the table. $q = "UPDATE photos SET image1=$fname1, image2=$fname2,..., WHERE id = $id"; , but I would like to update only newly submitted pictures and the old ones leave. $q = "UPDATE photos SET ".if(isset($fname1)){."image1=$fname1".}.", image2=$fname2,..., WHERE id = $id"; Guess I can't do it like the above code. Any help would be most welcome. Cheers Pete Link to comment https://forums.phpfreaks.com/topic/148363-update-query/ Share on other sites More sharing options...
opalelement Posted March 8, 2009 Share Posted March 8, 2009 I would SELECT them form the database, set $img1 = $row['fname1'] etc..., and then do an if statement to see if the image url changed... if it did, then set $img1 = $newimg1. then just upload them all with fname1 = $img1, fname2 = $img2, yadda yadda Link to comment https://forums.phpfreaks.com/topic/148363-update-query/#findComment-779287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.