mrt003003 Posted June 3, 2011 Share Posted June 3, 2011 Hi there im having trouble with a bit of code in that my form is not updating fully. I have a form with 2 list menus Here what im trying to do: <?php if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE fleet SET PlanetID=%s, Hyperspace=%s WHERE FleetID=%s", GetSQLValueString($_POST['select'], "int"), GetSQLValueString($_POST['select2'], "int"), GetSQLValueString($_POST['fleetid'], "int")); ?> I have 2 list menus select and select2. Select 1 is simple and updates fine: <select name="select"> <?php do {?> <option value="<?php echo $row_Planet['PlanetID']?>"><?php echo $row_Planet['PlanetName']?></option> The problem im having is with the 2nd list menu select2. <?php if($row_Distance['PlanetID'] == '5'){ $distance1 = '3'; $distance2 = '2'; $distance3 = '1'; $distance4 = '0'; $distance5 = '4';} else if ($row_Distance['PlanetID'] == '1'){ $distance1 = '0'; $distance2 = '2'; $distance3 = '3'; $distance3 = '1'; $distance4 = '4';} ?> <select name="select2"> <option value="<?php $distance1?>">Corella</option> <option value="<?php $distance2?>">Dantooine</option> <option value="<?php $distance3?>">Denab</option> <option value="<?php $distance4?>">Mon Calamari</option> <option value="<?php $distance5?>">Yagor Minor</option> </select> This is causing a problem and is not updating. Heres the relevant structure of my tables: FLEET FleetID PlanetID Hyperspace PLANET PlanetID Distance1 Distance2 Distance3 Distance4 Distance5 I have 5 planet records in my table in total and each record has Distance1-5 fields. The idea is that a user moves their fleet by choosing a planet from select and then again uses the 2nd select2 to choose the same planet labelly but actually sets the distance(which is conditioned in the php code above: Note im only testing so have only conditioned $distance for 2 of the 5 planets ). So if the user moved their fleet from Yagor Minor to Corella (using both selects) It would look like: PlanetName: 1, PlanetName: 3. I didnt really want to have to create 2 select fields but found so far it is the only way i can see around updating both the PlanetID value and the Hyperspace value (Distance from planet to other planet). Ultimately i would like to not have to use 2 select menus to accomplish this, but for now if i could just get it working that would be great. Can anybody help me please?? I hope ive explained myself well enough. Thanks for listening Quote Link to comment https://forums.phpfreaks.com/topic/238328-form-not-updating-fully/ Share on other sites More sharing options...
HenryC Posted June 3, 2011 Share Posted June 3, 2011 Echo the values. Quote Link to comment https://forums.phpfreaks.com/topic/238328-form-not-updating-fully/#findComment-1224774 Share on other sites More sharing options...
mrt003003 Posted June 3, 2011 Author Share Posted June 3, 2011 Ive echoed out all the $distance1-5 values and they all seem to be correct. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/238328-form-not-updating-fully/#findComment-1224778 Share on other sites More sharing options...
mrt003003 Posted June 3, 2011 Author Share Posted June 3, 2011 Oh yes echo inside the select!! Brilliant, all working thank you I dont suppose you know of a way i could update both values using only 1 select? Thanks again Henry Quote Link to comment https://forums.phpfreaks.com/topic/238328-form-not-updating-fully/#findComment-1224781 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.