I have a form with some multiple selection list boxes. I would like advice on how to insert data from these multiple selections into my tables- in fact I may need advice on my db table design.
These are my table designs:
organisation:
refno (primary key auto)
organisation
postcode
activity
legalstatus
ethnicity
activity table (holds list of activities that can be queried using select statement in listbox)
activity_id (primary key auto)
activity
activity_participant table (records multiple selections of activities)
activity_participant id (PK, auto)
activity_id (how do I make this foreign key?)
refno (identifies organisation- again how do I make this a foreign key?)
Here is my code at present:
include("connect.php");
error_reporting(E_ALL);
ini_set('display_errors', '1');
if (isset($_POST['Submit'])) {
$organisation= $_POST['organisation'];
$postcode= $_POST['postcode'];
$activity= $_POST['activity'];
$sql = "INSERT INTO nottsvcs, activity_participant (organisation, postcode, activity)"
VALUES ('$contact'
,'$postcode'
,'$activity')"
or die (mysql_error());
//execute query and store the result
$res = mysql_query($sql,$connection);
echo $res;
if ($res) {
echo "Your survey has been submitted - thankyou<BR /><BR />";
exit;
} else {
echo "There was a problem with your post - please click the back button and try again.<BR /><BR />";
}
}
?>