This is the form action after the check coding at above..
i want to check if the mark of the sudent for subjects is in the database,then block the data to insert into database..
but, in the check coding at above still inset the data which the query found data in the database..
hope can help me..
include 'db_connect.php';
// build the form action
if($_POST['Send'] == "Send"){
$id = $_POST['id'];
$term = $_POST['term'];
$year = $_POST['year'];
if(is_array($_POST['mark']) and
is_array($_POST['gred']) and
is_array($_POST['code']) and
is_array($_POST['subject']))
{
$values = array();
foreach($_POST['mark'] as $key => $mark)
{
if(!empty($mark)){
$gred = $_POST['gred'][$key];
$code = $_POST['code'][$key];
$subject = $_POST['subject'][$key];
$values[] = "('$id','$term','$yaer','$mark','$gred','$code','$subject')";
}
}
$query = "INSERT INTO result ".
"(id_stud, term, yaer, mark, gred, subject_code, name_subject) ".
"VALUES " . implode(",", $values);
$result = mysql_query($query) or die("Query failed: $query - " . mysql_error());
}
if ($sql) {
include 'page.php';
exit();
} else {
echo mysql_error();
}
}
?>