$query="SELECT sub_name,freetut_id FROM freetutorials"; $result = mysql_query ($query); echo "<select name='subject' value=''>Subjects</option>"; // printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[freetut_id]>$nt[sub_name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </li>
// Insert data into mysql $query = "INSERT INTO homeworkask ( dueon, subject, firstname, lastname, email, problems) " . " VALUES ('$dueon','$subject', '$firstname', '$lastname', '$email', '$problems')";
$result = mysql_query($query) or die('Unable to add product'); if ($result) echo "<h2>Your Homework has been Submitted. Check your email in about 24 hours.</h2>\n"; else echo "<h2>Problem Submitting your Homework.</h2>\n"; echo"<a href='index.php'>Back to main page</a>"; ?>
This is what happen in the database
homeworkask_id firstname lastname email subject dueon problems
59 sdfg fdsg sdfg 1 2011-01-01 fsfdgsd