I have a problem with mysql duplication. I have two tables name as student and temp_student. Both tables have same fields except for temp_student, i've add studentStatus and statusNote. The problem is, when I use mysql_num_rows
for any tables to search the duplication data, such as student name, it echos the duplication error. But when i use mysql_num_rows
for both tables, and i inserted the same student name into both table, the data still duplicate. Here is my code:
$name = $_POST['name'];
$checkName = mysql_query("select *from student where name = '$name'");
$checkNameTemp = mysql_query("select * from temp_student where name = '$name");
//$check = $checkName + $checkNameTemp;
if(mysql_num_rows($checkName) && mysql_num_rows($checkNameTemp) > 0){
echo "Duplicate Data";
}
else{
$insertStudentQuery = mysql_query("INSERT INTO student(name,noic, createDate) VALUES('$name','$Ic', NOW())");
$insertStudentQueryTemporary = mysql_query("INSERT INTO temp_student(name,noic, createDate) VALUES('$name','$Ic', NOW())");
}