Forum Moderators: coopster

Message Too Old, No Replies

Write to DB Using Dropdown

PhP - Mysql

         

Daxman23

10:16 am on Nov 6, 2007 (gmt 0)

10+ Year Member



Hey All!

I am a new member att this forum and would like to thank you all in advance for helping!

I have been asked by my boss to program a php dbase with several options to write to the database...

Everything works fine except that i can not be able to find any way to write to my dbase table using a dropdown box...

<option>Test</option>
I want TEST to be inserted into the dbase table but ive never had a worse blackout than this...HOW TO DO IT!?!?!:)

Thanks again!

Greetings,
Dax

[edited by: Daxman23 at 10:17 am (utc) on Nov. 6, 2007]

PHP_Chimp

10:39 am on Nov 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All of the $_GET/POST/REQUEST are arrays, so they need both index and value.
The index will be the name or id attribute, the value will be the...value ;)
So if you dont have a name/id for the select tag then im not sure what happens to the values of that tag.
So if you have -

<select>Somthing</select>
<option>test 1</option>
<option>test 2</option>

there is no index or value associated with the post.
However with -

<select name="something" id="something">Something</select>
<option value="test_1">test 1</option>
<option value="test_2">test 2</option>

should pass itself to the $_GET/POST/REQUEST array.

dreamcatcher

10:45 am on Nov 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good advice from PHP_Chimp. Its also worth noting that the value attribute for the <option> tag is optional. If no value is given, data will be sent between the tags. The value is only needed if you want to pass different data to the one presented to the viewer.

I guess the first thing to know is, what have you got so far? You say you can`t get it to work. Can you give us some brief code snippets?

dc

Daxman23

10:51 am on Nov 6, 2007 (gmt 0)

10+ Year Member



PHP Chimp..you are the bomb! :)

Got it solved and working just the way i wanted it!
Thanks a lot!

Dax

Habtom

11:24 am on Nov 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Little correction (if I haven't missed the point), it should be this way:

<select name="something" id="something">
<option value="test_1">test 1</option>
<option value="test_2">test 2</option>
</select>

. . . and Welcome to WebmasterWorld, Daxman23.

Habtom

PHP_Chimp

12:09 pm on Nov 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oops -
closing the select tag would have been a good idea.
Well at least you got the idea ;)