Jump to content

Form not updating fully


mrt003003

Recommended Posts

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 :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/238328-form-not-updating-fully/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.