combobox and mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dr.Mad
Forum Newbie
Posts: 2
Joined: Tue Sep 27, 2005 10:49 am

combobox and mysql

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Dr.Mad
Forum Newbie
Posts: 2
Joined: Tue Sep 27, 2005 10:49 am

Post 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
Post Reply