Okay, so after a couple of days of trial and error, I'm stuck again.....
Instead of having a row inserted in the intermediary table for each checked box, I'm getting one row, containing '0' as the value for sector_id, and only the value of the last checked box for service_id. It all looks okay to me, but as I said this is all fairly new to me. I'm going to keep trying, but it'd be great if someone could point out to me what I'm doing wrong. Here's my code (I initially set up the form in dreamweaver, but I'm making modifications by hand, if that makes a difference...)
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addregser")) {
$insertSQL = sprintf("INSERT INTO regional_services (Region_Id, Service_Name, Service_Purpose, Service_Description, Service_Impact, Service_www, Service_Contact_Name, Service_Contact_Email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_SESSION['Region_Id'], "int"),
GetSQLValueString($_POST['Service_Name'], "text"),
GetSQLValueString($_POST['Service_Purpose'], "text"),
GetSQLValueString($_POST['Service_Description'], "text"),
GetSQLValueString($_POST['Service_Impact'], "text"),
GetSQLValueString($_POST['Service_www'], "text"),
GetSQLValueString($_POST['Service_Contact_Name'], "text"),
GetSQLValueString($_POST['Service_Contact_Email'], "text"));
$Service_Id = mysql_insert_id();
$SectorId = $_POST['sector'];
foreach ($_POST['sector'] as $val) {
$insertSQL2 = sprintf("INSERT INTO target_sectors (Service_Id, Sector_Id) VALUES (%s, %s);",$Service_Id, $val);
}
mysql_select_db($database_ernact, $ernact);
$Result1 = mysql_query($insertSQL, $ernact) or die(mysql_error());
$Result2 = mysql_query($insertSQL2, $ernact) or die(mysql_error());
Cheers again!