从下拉列表中获取信息并在while循环中提交按钮?

I'm using a while loop to list "gladiators" from my game and what kind of training they are set to. I want the user to be able to set the training, using a drop down menu. So the page would look something like:

Gladiator 1 Training: Not set. Drop down menu | submit button

Gladiator 2 Training: Strength Drop down menu | submit button

...and so on, for all the gladiators registered to the users ludus. The drop down menu consists of the different types of training you can chose for each gladiator.

The code I use goes like this:

<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
    echo "You must be logged in to view this page!";
}
$uid=$_SESSION['uid'];
$husinfotemp=mysql_query("SELECT * from `hus` WHERE `id`='$uid'") or die (mysql_error());
$husinfo=mysql_fetch_assoc($husinfotemp) or die (mysql_error());
$nrofglads=$husinfo['nrofgladiators'];
$gladiatorsinfotemp=mysql_query("SELECT * FROM `gladiators`") or die (mysql_error());
$totalglads=mysql_num_rows($gladiatorsinfotemp);


$counter=1;
$countertotal=1;
while ($counter<=$nrofglads) {
    while ($countertotal<=$totalglads) {
        $gladiatorsinfotemp2=mysql_query("SELECT * FROM `gladiators` WHERE `gladiatorid`='$countertotal'") or die (mysql_error());
        $gladiatorsinfo=mysql_fetch_assoc($gladiatorsinfotemp2) or die (mysql_error());
        $ludusid=$gladiatorsinfo['ludusid'];
            if ($ludusid==$uid) {
                $name=$gladiatorsinfo['name'];
                $traininginfotemp=mysql_query("SELECT * FROM `training` WHERE `gladiatorid`='$countertotal'") or die (mysql_error());
                $traininginfo=mysql_fetch_assoc($traininginfotemp);
                $trainingtype=$traininginfo['trainingtype'];
                $trainingtypetext=trainingtotext($trainingtype);
                ?><font size="3"><?php
                echo "<a href=gladiator.php?gladiatorid=$countertotal>$name</a>";?>
                </font><br /><?php
                echo "Training: ".$trainingtypetext.".";
                ?>
                <form action="">
                <select name="training">
                <option value="1">Strength</option>
                <option value="2">Agility</option>
                <option value="3">Quickness</option>
                <option value="4">Stamina</option>
                <option value="5">Attacks</option>
                <option value="6">Defence</option>
                <option value="7">Sword</option>
                <option value="8">Mace</option>
                <option value="9">Pole</option>
                <option value="10">Dagger</option>
                <option value="11">Unarmed</option>
                <option value="12">Net</option>
                <option value="13">Shield</option>
                <option value="14">Sparring</option>
                </select>
                <input type="submit" class="button" value="submit" name="one"/>
                </form><?php
                if(isset ($_POST['one'])) {
                    if ($_POST['training']=='1') {
                        $trainingtype=1;
                        $updtraining=mysql_query("UPDATE `training` SET `trainingtype`='$trainingtype' WHERE `gladiatorid`='$countertotal'") or die (mysql_error());
                    }else echo "2";
                }

                $counter++;
                ?><br /><?php
            }
        $countertotal++;
    }


}



include ("footer.php");
?>

The problem is that when I click submit nothing is getting submitted. My question is if it is possible to use a while loop and this kind of drop down list + submit button system to set the training in the manner which I'm trying to use here?

To the experienced coders out there: I'm sorry you have to read such terrible code, I am a slacker trying to learn by reading simple uides whenever I stumble upon a problem. Not the best way to learn to create good code, I'm afraid ;)

As far as the forms are concerned; you are adding the same button with the same name to all your forms, so you will not be able to distinguish which button was pressed.

A more logical solution would be to put your processing of the sent-in form at the top and add a hidden field to each form with the gladiatorid so that you know exactly which item the sent-in value applies to.

Apart from that you should switch to PDO or mysqli as the mysql_* functions are deprecated.

Well, firstly if you intend to submit a form, you must provide it a right action source to submit the form to, secondly you if you intend to use a POST method, this should be addressed in the form's properties as well:

<form action='myfile.php' method='post'>

and one more important thing, you are using a depreciated functions for connecting and querying Mysql, you should use Mysqli or PDO extentions and use binding to prevent future SQL injections.

Thanks for your replies. You helped me into finding a solution. I removed the if (isset ... part, and worked a bit using your tips and google->a guide. Now the form part looks like this:

<form action="settraining.php" method="post">
            <select name="training">
            <option value="1">Strength</option>
            <option value="2">Agility</option>
            <option value="3">Quickness</option>
            <option value="4">Stamina</option>
            <option value="5">Attacks</option>
            <option value="6">Defence</option>
            <option value="7">Sword</option>
            <option value="8">Mace</option>
            <option value="9">Pole</option>
            <option value="10">Dagger</option>
            <option value="11">Unarmed</option>
            <option value="12">Net</option>
            <option value="13">Shield</option>
            <option value="14">Sparring</option>
            <input type="hidden" name="gladiatorid" value="<?php echo "$countertotal" ?>">
            </select>
            <input type="submit" class="button" value="submit" name="one"/>
            </form>

And on settraining I get the information using:

$trainingtype = htmlspecialchars($_POST['training']);
$gladiatorid=htmlspecialchars($_POST['gladiatorid']);

And it seems like everything works fine :)