blui Posted March 25, 2007 Share Posted March 25, 2007 Hi all, still trying to get my head round this php coding, hoping someone can help. I current have a form which creates 5 links from drop down menus and a second page which updates the database with the new values. I have managed to get it working with 1 value but for some reason, it will only update teh last value not all 5 of them. Can anyone see were I'm going wrong? all help is greatly appreciated. my code is shown below:- phpinfo.php <form action="../php/postinfo2.php" method="post"> <label>Choose your image for 1 <select name="imagelist"> <? require('directorylistinginc.php'); ?> </select> </label> <br /> <label>Choose your image for 2 <select name="imagelist2"> <? require('directorylistinginc.php'); ?> </select> </label> <label><br /> Choose your image for 3 <select name="imagelist3"> <? require('directorylistinginc.php'); ?> </select> </label> <br /> <label>Choose your image for 4 <select name="imagelist4"> <? require('directorylistinginc.php'); ?> </select> </label> <br /> <label>Choose your image for 5 <select name="imagelist5"> <? require('directorylistinginc.php'); ?> </select> </label> <input type="submit" name="submit" value="submit"> </form> ----------------------------------------------------------------- phpinfo2.php <? require_once('connectionlocal.php'); ?> <?PHP //inserts image link into approprate cell $sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist]' WHERE `PRIMARYID`=1 "; $sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist2]' WHERE `PRIMARYID`=2 "; $sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist3]' WHERE `PRIMARYID`=3 "; $sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist4]' WHERE `PRIMARYID`=4 "; $sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist5]' WHERE `PRIMARYID`=5 "; $queryResult = mysql_query($sql) or die("An error has happened: " . mysql_error()); ?> <?php // Change to the URL you want to redirect to $URL="http://pauldaleragu/php/postinfo.php"; header ("Location: $URL"); ?> Link to comment https://forums.phpfreaks.com/topic/44210-solved-not-updating-database/ Share on other sites More sharing options...
papaface Posted March 25, 2007 Share Posted March 25, 2007 You have loads of variables named the same thing. You need to name and run each one seperately. Link to comment https://forums.phpfreaks.com/topic/44210-solved-not-updating-database/#findComment-214720 Share on other sites More sharing options...
AndyB Posted March 25, 2007 Share Posted March 25, 2007 You need to execute each query in phpinfo2.php. You're only executing the last one. Link to comment https://forums.phpfreaks.com/topic/44210-solved-not-updating-database/#findComment-214723 Share on other sites More sharing options...
blui Posted March 25, 2007 Author Share Posted March 25, 2007 Thanks for your pointers - I now have it working correctly Link to comment https://forums.phpfreaks.com/topic/44210-solved-not-updating-database/#findComment-214791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.