I have a section of a form containing a few checkboxes that are ALL OPTIONAL.
However, the foreach loop that I have below gives an error that says "Invalid argument supplied" when NONE of the checkboxes are checked.
How can I avoid this error?
I simply want to NOT execute the INSERT INTO statement if nothing was checked.
Thank you.
foreach ($_POST['credit_label'] as $key => $value) {
$credit_label_id = $_POST['credit_label'][$key];
$sql = "INSERT INTO `credit_labels_course` (`course_id`, `credit_label_id`)
VALUES (\"$new_course_id\", \"$credit_label_id\");";
$result = mysql_query($sql,$dbc);
}