Value from drop down list not being passed to database

From: Date: Fri, 04 Oct 2002 20:50:11 +0000
Subject: Value from drop down list not being passed to database
Groups: php.db 
Request: Send a blank email to php-db+get-22217@lists.php.net to get a copy of this message
I have a table with a combi box drawing values from one table in a database and this should be inserted into another table along with other information: <FORM NAME="Table1FORM" ACTION="submit_new_unit.php" METHOD=POST> <TABLE ID="Table1" BORDER=1 BGCOLOR="#FFFFCC" CELLSPACING=3 CELLPADDING=1 WIDTH="100%"> <TR> <TD WIDTH=142> <P ALIGN=RIGHT><B>Course ID :</B></P> </TD> <TD WIDTH=365> <P> <SELECT ID="Forms Combo Box1" NAME="FormsComboBox1" <?include ("../config.inc.php"); mysql_select_db("grange") or die ("unable to access database:".mysql_error());?> <?php $results = mysql_query("select course_id from courses") or die("Unable to process queries at this time: " . mysql_error()); echo("<option value=''>other</option>\n"); echo("<option value='' >Select Course</option>\n"); while ($crs = mysql_fetch_array($results)) { $course= $crs["course_id"]; echo("<option value='$course'>$course </option>\n"); } ?>> </SELECT> </TD> </TR> <TR> <TD WIDTH=142> <P ALIGN=RIGHT><B>Unit ID :</B></P></TD> <TD WIDTH=365> <P><INPUT ID="Forms Edit Field4" TYPE=TEXT NAME="unit_id" VALUE="" SIZE=44 MAXLENGTH=44></TD> </TR><TR> <TD WIDTH=142> <P ALIGN=RIGHT><B>Unit Name :</B></P></TD> <TD WIDTH=365> <P><INPUT ID="Forms Edit Field5" TYPE=TEXT NAME="unit_name" VALUE="" SIZE=44 MAXLENGTH=44></TD> </TR> <TR> <TD WIDTH=142> <P ALIGN=RIGHT><B>Unit Outcomes :</B></P> </TD> <TD WIDTH=365> <P><TEXTAREA WRAP=PHYSICAL ID="Forms Multi-Line1" NAME="unit_outcomes" ROWS=3 COLS=42></TEXTAREA></TD></TR> <TR><TD WIDTH=142><P ALIGN=RIGHT><B>Requirements :</B></P></TD> <TD WIDTH=365><P><INPUT ID="Forms Edit Field7" TYPE=TEXT NAME="requirements" VALUE="" SIZE=44 MAXLENGTH=44></TD> </TR> <TR><TD WIDTH=142><P ALIGN=RIGHT><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=0 NOF=TE> <TR><TD ALIGN="LEFT"><INPUT TYPE=SUBMIT NAME="FormsButton3" VALUE="Clear Form" ID="Forms Button3"></TD></TR> </TABLE></TD> <TD WIDTH=365><P><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=0 NOF=TE><TR> <TD ALIGN="RIGHT"><INPUT TYPE=SUBMIT NAME="FormsButton4" VALUE="Enter Unit" ID="Forms Button4"></TD></TR> </TABLE></TD></TR> </TABLE> </FORM> Information passes to a "submit" page to insert the code into the database: <?include ("../config.inc.php"); ?> <?php //receive and handle data generated by enter_unit.php $query = "insert into units (course_id, unit_id, unit_name, unit_outcomes, requirements) values ('".$course."', '".$unit_id."', '".$unit_name."', '".$unit_outcomes."', '".$requirements."')"; echo ("The query is: <BR>$query<P>\n"); if (mysql_db_query ($dbname, $query, $link)){ echo ("The unit was successfully inserted. <BR>\n"); } else { echo (mysql_error()); } mysql_close ($link); ?> My problem is that all the data is being inserted correctly except the data from the drop down box.

« previous php.db (#22217) next »