MYSQL (attendance) Table:
--------------------------------------------------------
| ID | EmployeeID | Name | TimeIn | TimeOut | Date |
+----+------------+------+--------+---------+----------+
| 4 | 7 | Jack | 4 | 16 | 18-11-16 |
+----+------------+------+--------+---------+----------+
| 5 | 7 | Jack | 4 | 16 | 19-11-16 |
+----+------------+------+--------+---------+----------+
| 6 | 8 | Dave | 4 | 16 | 19-11-16 |
+----+------------+------+--------+---------+----------+
PHP code to insert a new row:
$SQL = "INSERT INTO attendance (ID, EmployeeID, Name, TimeIn, TimeOut, Date) VALUES ('$ID', '$EmployeeID', '$Name', '$TimeIn', '$TimeOut', '$Date');";
$Results = mysql_query($SQL);
if (!$Results){
echo "Error inserting data.";
}
According to my code, the user can record same row (same attendance) for the same employee and in the same time (duplicate) like the following:
--------------------------------------------------------
| ID | EmployeeID | Name | TimeIn | TimeOut | Date |
+----+------------+------+--------+---------+----------+
| 6 | 8 | Dave | 4 | 16 | 19-11-16 |
+----+------------+------+--------+---------+----------+
| 7 | 8 | Dave | 4 | 16 | 19-11-16 |
+----+------------+------+--------+---------+----------+
How to make sure I'm not inserting the same row twice?
Please let me know if you need more information. I appreciate your help.