I cannot insert the student id to table. Would you mind give me some recommentation,please!
<body>
<form id="form1" name="form1" method="post" action="">
<?php
/* This page receives and handles the data generated by "form.html". */
// $_POST["FirstName"] is an array!!
$total = count($_POST["checkbox"]);
// print "Number of FirstName(s) submitted: " . total;
$eca_id = $_POST["eca_id"];
for ($i=0; $i<$total; $i++) {
if(isset($_POST["Submit"])){
$fruit=isset($_POST["checkbox"]["0"])?$_POST["checkbox"]["0"]:"";
if(isset($_POST["checkbox"]["$i"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["checkbox"]["$i"];
}
}
// Note: The FirstNames are stored as
// $_POST["FirstName"]["0"], $_POST["FirstName"]["1"], etc
print "ECA_ID: " . $_POST["eca_id"]["$i"]. ".<BR>\n";
print "ID: " . $_POST["checkbox"]["$i"] . ".<BR>\n";
$insertSQL = sprintf("INSERT INTO enrollment (eca_id,id) VALUES ('%s','%s')",
$eca_id[$i],
$fruit[$i]);
mysql_select_db($database_connection, $connection);
$Result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
}
?>
</form>