INSERT into mysql from dynamic drop down
| From: | irinchiang at justeducation dot com | Date: | Wed, 07 Jan 2004 06:37:06 +0000 |
| Subject: | INSERT into mysql from dynamic drop down | ||
| Groups: | php.db php.general | ||
| Request: | Send a blank email to php-db+get-32307@lists.php.net to get a copy of this message | ||
Hi all,
Right now i would like to INSERT the values from a dynamic drop down
menu into mysql database but encountered some problem here. Values in the drop
down menu are retrieved from DB as follows:
<SNIP>
<SELECT NAME="tutor_name" CLASS="textarea">
<?
$sql = mysql_query("SELECT DISTINCT tutor_name FROM tutor");
while ($row = mysql_fetch_array($sql))
{
print "<OPTION VALUE=\"$tutor_name\" >" .$row["tutor_name"].
"</option>";
}
$result = $db->query($sql);
?>
</SELECT>
</SNIP>
-------------------------------------------------------------------------------
echo $_POST["tutor_name"];
INSERT statement:
$sql = "INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,
timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time')";
-------------------------------------------------------------------------------
I am trying to POST the values and then INSERT into DB but was not able to do
so....(all other values eg. class_code, edu_level etc...was able to be
INSERTED into DB but not "tutor_name". So, how do i insert values into DB from
a dynamic drop down and where have i gone wrong???Hope to get some help real
soon.=)
All help are greatly appreciated. Thanks in advance.
Regards,
Irin.