468,315 Members | 1,414 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

How do you insert a value from drop down list to SQL table?

Ren
Hi all,

I am a bit new to PHP and SQL so this may seem like a dumb question.

I have already created a drop down list as part of a form which is
automatically populated with values taken from a separate database. When a
user goes onto this page and either leaves the default value or selects a
value from the drop down list and presses the submit button, I would like
that selected value to be stored into a database which I have already
created in SQL.

Just to let you know that I can do the above using a text field but just
don't know how to do it with drop down list.

If your going to explain any coding then it may help if I give you the names
of certain items that are involved.

Database is called "Company"
Field within database is called "Name"

Drop down list is called "company"

Thanks
Ren
Jan 26 '06 #1
2 4356
Ren wrote:
Hi all,

I am a bit new to PHP and SQL so this may seem like a dumb question.

I have already created a drop down list as part of a form which is
automatically populated with values taken from a separate database. When a
user goes onto this page and either leaves the default value or selects a
value from the drop down list and presses the submit button, I would like
that selected value to be stored into a database which I have already
created in SQL.

Just to let you know that I can do the above using a text field but just
don't know how to do it with drop down list.

If your going to explain any coding then it may help if I give you the names
of certain items that are involved.

Database is called "Company"
Field within database is called "Name"

Drop down list is called "company"

Thanks
Ren


Ren,

Submit your form to a simple testpage which contains the following:

print_r($_POST);

or - depending on your php version -

print_r($HTTP_POST_VARS);
You should now see exactly what is being submitted by your form (and
how) which should tell you how you can reference the value you want to
put into your database.

Grz,
Juliette
Jan 26 '06 #2
Ren
Thanks Juliette for the reply.

Just to let you know that I made a stupid typing error in the php code that
is why it was not working.

Sorry about that!
Ren
"Juliette" <jr*********@jokeaday.net> wrote in message
news:43***********************@news.wanadoo.nl...
Ren wrote:
Hi all,

I am a bit new to PHP and SQL so this may seem like a dumb question.

I have already created a drop down list as part of a form which is
automatically populated with values taken from a separate database. When
a user goes onto this page and either leaves the default value or selects
a value from the drop down list and presses the submit button, I would
like that selected value to be stored into a database which I have
already created in SQL.

Just to let you know that I can do the above using a text field but just
don't know how to do it with drop down list.

If your going to explain any coding then it may help if I give you the
names of certain items that are involved.

Database is called "Company"
Field within database is called "Name"

Drop down list is called "company"

Thanks
Ren


Ren,

Submit your form to a simple testpage which contains the following:

print_r($_POST);

or - depending on your php version -

print_r($HTTP_POST_VARS);
You should now see exactly what is being submitted by your form (and how)
which should tell you how you can reference the value you want to put into
your database.

Grz,
Juliette

Jan 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Martyn Fewtrell | last post: by
4 posts views Thread by TycoonUK | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.