hello Everyone i have codes that updates the student records.
$select_query="select student_id from student_information where student_id = '$student_id'";
$result_set = mysql_query($select_query,$link_id);
if($row = mysql_fetch_array($result_set)){
$flag="exists";
header("location:Admin_Home.php?flag=$flag&student_id=$student_id");
die();
}
else{
/*
This block is used to insert the learners record in database
if the student_id is not yet registered in the database.
*/
mysql_query("SET AUTOCOMMIT = 0 ");
if(mysql_error() != null){
die(mysql_error());
}
$query = "insert into student_information(student_id,student_password,first_name,last_name,registration_date,gender,date_of_birth,";
$query .= "contact_no,grade,section,LRN,email1,email2,address,description,learner_id)";
$query .= " values('$student_id','$student_password','$first_name','$last_name',now(),'$gender','$date_of_birth',";
$query .= "'$contact_no','$grade','$section','$LRN','$email1','$email2','$address','$description','$learner_id')";
$result = mysql_query($query,$link_id);
if(mysql_error() != null){
die(mysql_error());
}
}
Now, my problem is to put a script that alerts that the “records has been updated” and from what part of this code be it inserted.
Well, I’d put it at the end - where you have an if() check to look for errors, add an ‘else’ to show the message when there aren’t any errors.
if (mysql_error() != null){
die(mysql_error());
}
else
{
echo "All seems to work";
}
If this is new code, you seriously need to look at dropping the mysql calls and use mysqli or PDO instead. There’s a sticky at the top of this forum leading to articles about how any why you need to do this.