Re: Re: Display Mysql Result in drop down list

From: Date: Tue, 23 Dec 2003 09:32:39 +0000
Subject: Re: Re: Display Mysql Result in drop down list
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-32171@lists.php.net to get a copy of this message
Hi: then now i'm trying to select a value from the drop down list, echo the value i have selected and lastly INSERT the value into DB with the following : Below's a snippet of code: <snip> //retrieve all "tutor_name" from DB and display in drop down list <SELECT class="textarea" name="tutor_name" /> <? $sql = mysql_query("SELECT tutor_name FROM tutor "); while ($row = mysql_fetch_array($sql)) { print "<OPTION VALUE=\"$tutor_name\" SELECTED>" .$row ["tutor_name"]. "</option>"; } $result = $db->query($sql); ?> </select> </snip> <snip> ***********************INSERT selected values into DB************************** $tutor_name = $_POST["tutor_name"]; $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')"; //execute query statement $result = $db->query($sql); </snip> <snip> *********************echo the value i have selected*************************** <? if($selected_tutor_name == $tutor_name) echo $_POST["tutor_name"]; ?> </snip> Problem: I was unable to echo the value i selected from drop down as well as INSERT into DB...wonder where have i gone wrong??? Reali need some help here...all help are greatly appreciated =) Thanks in advance. Irin.

« previous php.db (#32171) next »