Help? Before I explode with drop menu

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
illmapu
Forum Commoner
Posts: 47
Joined: Fri Aug 22, 2003 1:48 pm

Help? Before I explode with drop menu

Post by illmapu »

Hi,

I've looked through the php normal forum for an answer for several hours, but still no luck.

I have a simple form that the user adds their website and title, but I am trying to add a drop menu of categories for them to choose from.

The problem I 'm having is that the website and title are going into the db, but I cannot for the life of me, get info from the drop menu to go into the db too.

Can anyone help? :oops:

Thanks in advance!
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Code: Select all

<select name="foo">
 <option>Something
 <option>Else
 <option>Other
</select>
When submitting the form, $_POST['foo'] will have a value of one of the 3 above... Hope it helped.
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

illmapu: could you post some of your code so we can see whats going on?
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

JAM wrote:

Code: Select all

<select name="foo">
 <option>Something
 <option>Else
 <option>Other
</select>
When submitting the form, $_POST['foo'] will have a value of one of the 3 above... Hope it helped.
Nope, that's not entirely correct. As posted above $_POST['foo'] would be empty.

Code: Select all

<select name="foo">
<option value="Chad">Chad
<option value="Chile">Chile
<option value="China">China
<option value="Colombia">Colombia
</select>
Provided the form-values are submitted via POST, $_POST['foo'] will have the value of the option the user selected.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

not true.
http://www.w3.org/TR/html4/interact/forms.html#edef-OPTION
value = cdata [CS]
This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the OPTION element.
But please, could you close the tags you've opened? ;)

Code: Select all

<select name="foo">
	<option>Something</option>
	<option>Else</option>
	<option>Other</option>
</select>
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Excellent. I didn't know that. Thanks, Volka :)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

For PatrikG, a link.
But please, could you close the tags you've opened?
Of course, I should. It's becomming a bad habit when I do testing... (As picture shows)... =/

/me slaps self...
illmapu
Forum Commoner
Posts: 47
Joined: Fri Aug 22, 2003 1:48 pm

Thank you!

Post by illmapu »

I appreciate everyones feedback. I discovered what I was doing wrong and won't ever forget it again!

Simply put, after hours and hours of sitting in front of my pc, I realized that I never put the name of the drop box into my sql query to insert as I did with everything else in the form, so that's why it wasn't posting.. Chalk it up to too many hours :oops:

8O
Post Reply