SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old September 18th, 2004, 08:15 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 49 sec
Reputation Power: 0
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~

Reply With Quote
  #2  
Old September 19th, 2004, 02:23 AM
oyejorge oyejorge is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 oyejorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 13 sec
Reputation Power: 0
The name=attribute portion that your talking about should be in the <select> tag:

<select name="country_id">

Reply With Quote
  #3  
Old September 19th, 2004, 05:00 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 49 sec
Reputation Power: 0
hmmm, i did that, but it hasn't fixed the problem. Thanks for the tip though.

~magda~

Reply With Quote
  #4  
Old September 19th, 2004, 05:17 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 49 sec
Reputation Power: 0
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~

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > selected value from drop down box won't insert into db


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway