You are here: Re: How do you insert a value from drop down list to SQL table? « All PHP « IT news, forums, messages
Re: How do you insert a value from drop down list to SQL table?

Posted by Blockhead on 01/26/06 21:35

If I am reading your problem correctly, then it will be very easy for
you to succeed. If you are able to successfully INSERT into your DB
when using a regular text field, then you can also do it using a menu
or <select> field. PHP doesnt care what type of html field is in the
form, only the name of the field, which becomes the name of the "POST"
or "GET" variable containing the value of the field.

A common mistake however is that when creating a menu, most people
forget to actually assign a value to each option, so even though
various menu choices appear to the user, when they click submit, a NULL
or empty value is submitted with the form.

This will look right on the screen but not not work properly:
<select name="menu1">
<option>item 1</option>
<option>item 2</option>
<option>item 3</option>
</select>

this is how it needs to be:
<select name="menu1">
<option value ="item 1">item 1</option>
<option value ="item 2">item 2</option>
<option value ="item 3">item 3</option>
</select>

then on your submission page, if the form was submitted via POST, you
would just grab the value in the same way that you grabbed a regular
text field
$sMenu1 = $_POST["menu1"];

if that isnt your problem, perhaps you could post your code?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация