Hi,
Here's my problem. I've setup the following bit of code to display a checkbox list from a database:
while ($row = mysql_fetch_array($sql_result)) {
$areaid = $row["certid"];
$description = $row["description"];
$option_block .= "<INPUT TYPE=CHECKBOX NAME=\"description[]\"
VALUE=\"$description\">
<INPUT TYPE=HIDDEN NAME=\"areaid\" value=\"$areaid\">$description
<b>$$areaid</b></br>";
This displays properly with output similar to this:
Description ID
Vocational Education |21
Chemistry |22
English |23
The user can check as many boxes as are applicable.
I want to take only the ID values that the user selects from the above and enter them into a different database table. Here's where it gets messed up:
while($x = each($description))
echo "$x[1] <b>$areaid</b><BR>";
$query = "INSERT INTO tblapplicantcerts (ApplicantID, CertID)
VALUES ('$val', '$areaid')";
$sql_result = mysql_query( $query )
or die("Couldn't execute tempdone query.");
The $val is a user ID variable.What happens is that no matter which checkbox the user selects (English, Vo-Ed, etc.) the $areaid value that gets inserted into the database is the last ID number in the list. So, if a user selects Chemistry the ID number shows as 23, not 22.
I'm new at this, so could someone show me how to write the WHILE statement so it executes properly?
Thanks,
John