title: How to check for a duplicate row before inserting using PHP
body: <p><strong>MYSQL</strong> (attendance) Table:</p>
  
  <pre><code>--------------------------------------------------------
  | 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 |
  +----+------------+------+--------+---------+----------+
  </code></pre>
  
  <p><strong>PHP code to insert a new row:</strong></p>
  
  <pre><code>$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.";
  }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>--------------------------------------------------------
  | ID | EmployeeID | Name | TimeIn | TimeOut | Date     |
  +----+------------+------+--------+---------+----------+
  | 6  | 8          | Dave |   4    |    16   | 19-11-16 |
  +----+------------+------+--------+---------+----------+
  | 7  | 8          | Dave |   4    |    16   | 19-11-16 |
  +----+------------+------+--------+---------+----------+
  </code></pre>
  
  <p>How to make sure I'm not inserting the same row twice?</p>
  
  <p>Please let me know if you need more information. 
  I appreciate your help.</p>