Page 1 of 1

combobox and mysql

Posted: Tue Sep 27, 2005 11:01 am
by Dr.Mad
Hello all, I'm new to PHP programming.
I've come accross a problem which I can't resolve. I have a php page with a form containing a combobox. In that box, you have 3 choices: modify, delete and add.
The form uses POST method and has as action="execute.php" meaning that when I push on the submit button, the execute.php page is loaded.

Now, the problem is that this execute.php page needs to know which option was selected in the combobox. Is there somehow a way to give a variable to execute.php which tells it what option is selected at the moment the submit button is pressed?
Here is the code of the form:
code wrote: <form method=post action="execute.php" name="form1">
<select name="choice">
<option name="oper" value=0> Modify </option>
<option name="oper" value=1> Delete </option>
<option name="oper" value=2> Add </option>
</select>
</form>
I have tried to put this on the execute.php page:
code wrote: <?php
print("$oper");
//I have also tried with:
print("$choice");
?>
But no luck... the value of $oper (or $choice) on execute.php is always a null value while I need to know if it's modify, delete or add that was selected.
If anyone can help me, I'd be very grateful!

Thanks

Posted: Tue Sep 27, 2005 11:05 am
by s.dot
remove the name from the <option> tag so you have <option value="1"> <option value="2"> and <option value="3">

Then, this value will be in $_POST['choice'] (the name of the select box) when you submit the data.

Posted: Tue Sep 27, 2005 11:11 am
by Dr.Mad
scrotaye wrote:remove the name from the <option> tag so you have <option value="1"> <option value="2"> and <option value="3">

Then, this value will be in $_POST['choice'] (the name of the select box) when you submit the data.
I will try that out right away. I'll keep you posted. Thanks already.

EDIT: Didn't work :(
The form looks like this now:
code wrote: <form method=post action="execute.php" name="form1">
<select name="choice">
<option value=0> Modify </option>
<option value=1> Delete </option>
<option value=2> Add </option>
</select>
and execute.php is this:
code wrote: <?php print("$choice"); ?>
This thing is drivin me mad 8O