Janabl
Janabl

Reputation: 7

can't get value from select out of DB

I have a problem with getting a value out of a select which gets it's options out of the database. I've tried looking for a solution but I can't seem te find an answer because the options aren't hard coded.

This is the option select:

<select id="selectmission" name='missionselect' onchange='showoptions()'>
              <?php while($mission = $allmissions->fetch_assoc())
        { echo "<option value='".$mission['missionid']."'>".$mission['missionname']."</option>";?>
                <option value="other">Other</option>
                </select>

This is the php:

if(isset($_POST['btnSubmit']))
    {
        try
        {
            $t->Description = $_POST['description'];
            if($_POST['missionselect'] = 'other')
            {
                $m->Missionname = $_POST['missionname'];
                $m->CreateNewMission();
            }
        else
            {
                $t->Missionid = $_POST['missionselect'];
            }

I have tried to let it echo the value it identifies by using this code:

$select = $_POST['missionselect'];
echo $select;

It showed that it always detects the option 'other', the only hardcoded option.

I hope somebody can see what I've missed! Thanks guys, Jana

Upvotes: 0

Views: 54

Answers (1)

GDP
GDP

Reputation: 8178

Perhaps this change:

if($_POST['missionselect'] = 'other')
if($_POST['missionselect'] == 'other')

Upvotes: 1

Related Questions