Jump to content

Recommended Posts

Hi there, Im trying to update 2 variables by using only 1 list/menu. Im really not sure how to go about this.

 

Currently I have a form with 2 list menus that updates the 2 variables but as you will see 2 list/menus are really not needed here as its more for a user to input.

Ok so ive got 2 tables:

FLEET

FleetID

PlanetID

Hyperspace

 

PLANET

PlanetID

Distance1

Distance2

Distance3

Distance4

Distance5

 

I have 5 planet records in my table in total and each Planet record has Distance1-5 fields to simulate the distance from each other. 

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 below).

So if the user moved their fleet from Yagor Minor to Corella (using both selects) It would look like: PlanetName: 1, PlanetName: 3.

 

I want to be able to update both the new PlanetID value in Fleet AND the Hyperspace value (Number of turns) in Fleet with a single list/menu, I just really dont know how to go about it.

 

<?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")); ?>

<select name="select"> 
<?php do {?> 
<option value="<?php echo $row_Planet['PlanetID']?>"><?php echo $row_Planet['PlanetName']?>
</option>

<?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>

 

Any ideas?

 

Thanks :)

 

[attachment deleted by admin]

Your FLEET table should have the location of the fleet and it's destination as columns. The location takes care of your first selection and renders it unnecessary, like you want. When the user selects the destination from the dropdown menu it should be entered along with the number of turns into the FLEET table.

 

You then count down the Hyperspace value till it hits zero at that time you put the destination into the location  column and zero out the destination  column and give the player another turn...  All good unless player has more than one fleet.

Hi sunfighter and thanks for the reply,

 

I see what you mean about using location and destination as columns in the Fleet table . The trouble is the user can have many fleets and I cant quite get my head around how that would cause a problem in the way you suggested. Could you elaborate a little for me please? Sorry im quite new to this.

 

Thank You :)

What I was thing was, the user might have to choose which fleet he was moving and that gets you back to two dropdowns. Or, You keep track of the fleets that he could move and present it to him, one at a time. But if he had the choice of moving or staying still, He again has two choices.

 

But the extra column I talked about in my first reply is good. You just need to add that to all the fleets the player owns.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.