|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
selected value from drop down box won't insert into db
I have a form with several text fields and a drop down box that's been populated with data from a table in the db. When the submit button is pressed, the text in the fields and the value of the selection made in the drop box is supposed to be inserted into the db as a new record. However, the value from the dropbox isn't being inserted. The text in the text fields is, but the field where the drop box value is supposed to be only has "0" there.
this is the code i used to populate the drop box: <?php $countryresult = mysql_query("SELECT * FROM dvdcat_country",$db); echo "<p>Country of origin<select>\n"; if ($myrow = mysql_fetch_array($countryresult)) { do { printf("<option value=".$myrow['country_id'].">".$myrow['country_name']."</option>\n"); } while ($myrow = mysql_fetch_array($countryresult)); echo "</select></p>\n"; } else { echo "Sorry, no records were found!"; } ?> and this is the insert sql script that executes when the submit button is pressed: $sql = "INSERT INTO dvdcat_featurepres (featurepres_name,featurepres_imdbid,country_id) VALUES ('$featurepres_name','$featurepres_imdbid','$count ry_id')"; $result = mysql_query($sql); like i said before, the first two values (which are in text fields) insert successfully but the third value does not. It seems to be a matter of the <option> tag not having a name= attribute like the text fields do, but inserting that attribute causes a parse error. Or maybe it does read the value attribute when it submits, but it's confused by the value attribute? Any help is appreciated. ~magda~ |
|
#2
|
|||
|
|||
|
The name=attribute portion that your talking about should be in the <select> tag:
<select name="country_id"> |
|
#3
|
|||
|
|||
|
hmmm, i did that, but it hasn't fixed the problem. Thanks for the tip though.
~magda~ |
|
#4
|
|||
|
|||
|
I've got it working now - I'm not sure what did it. It may have just been the mysql server playing up. Thanks again for the help.
~magda~ |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > selected value from drop down box won't insert into db |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|