Since I had such great success with my last question on this forum, I thought I would try again. I am creating a form for teachers to input the names of students who scored 100% of a principal’s math test. On this form, I want teachers to be able to enter up to 10 student information at a time and each one becomes a row in my database table.
Basically, I have an html form with entries like this:
Quarter: (checkboxes for 1,2.3.0r 4)
Teacher: (text field)
Student 1: First Name (text field firstname) Last Name (text field lastname) Id (text field id#)
Student 2: First Name (txt field firstname2) Last Name (text field lastname2) Id (text field id#2)
and so forth up to 10
I want to post this information into my table that has the following fields:
id (auto increment)
firstname
lastname
id#
I created a php script with some information I found on the web for doing such a thing, but I get nothing, no records created and no syntax errors:
<?php $con = mysql_connect("localhost","xxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("redwood", $con); $sql="INSERT INTO math (Quarter, Teacher, FirstName, LastName, Id#) VALUES ('$_POST[Quarter]','_$Post[Teacher]'), ('$_POST[firstname]','$_POST[Lastname]','$_POST[Id#]'), ('$_POST[firstname2]','$_POST[lastname2]','$_POST[id#2]'), ('$_POST[firstname3]','$_POST[lastname3]','$_POST[id#3]'), ('$_POST[firstname4]','$_POST[lastname4]','$_POST[id#4]'), ('$_POST[firstname5]','$_POST[lastname5]','$_POST[id#5]'), ('$_POST[firstname6]','$_POST[lastname6]','$_POST[id#6]'), ('$_POST[firstname7]','$_POST[lastname7]','$_POST[id#7]'), ('$_POST[firstname8]','$_POST[lastname8]','$_POST[id#8]'), ('$_POST[firstname9]','$_POST[lastname9]','$_POST[id#9]'), ('$_POST[firstname10]','$_POST[lastname10]','$_POST[id#10]')" ;if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); if ($_POST["Quarter"]) { # do something header("Location: viewmath.php"); exit; } ?>Any suggestions or how I should have done this correctly or if it is even possible?
Nancy
[Note from Moderator: Edited title of thread based on user’s second post!]