title: recording of timein and timeout in php
body: <blockquote>
  <p>I'm trying to make an attendance monitoring wherein a person can timein and timeout as many as he/she wish as long as it will be recorded to the database.</p>
  </blockquote>
  <pre><code>id   idnumber    datein      timein     dateout     timeout
  
  1     123      2013-02-21   08:00:01   2013-02-21   11:12:45
  
  2     456      2013-02-21   10:15:01   2013-02-21   05:30:01
  
  3     123      2013-02-21   06:58:52   2013-02-21   03:20:16
  
  4     123      2013-02-21   10:05:35   2013-02-21 
  </code></pre>
  <blockquote>
  <p>Can anyone give me an insert/update codes in php?</p>
  <p>I have this code that can insert idnumber if not exist and update if exist.</p>
  </blockquote>
  <pre><code>$query = &quot;SELECT * FROM tblattendance WHERE idnumber='&quot;.$_POST[idnumber'].&quot;'&quot;;
  $res = mysql_query($query);
  list($exist) = mysql_fetch_array($res);
  
      if (!$exist){
            $query = &quot;INSERT INTO tblattendance SET idnumber='&quot;.$_POST['idnumber'].&quot;', datein=CURDATE(), timein = CURTIME()&quot;;
            $insert_result = mysql_query($query);
      }else{
           $query1 = &quot;UPDATE tblattendance SET dateout=CURDATE(), timeout = CURTIME() WHERE idnumber='&quot;.$_POST['idnumber'].&quot;' ORDER BY id DESC LIMIT 1 &quot;;
           $insert_result1 = mysql_query($query1);    
      }
  </code></pre>
  <blockquote>
  <p>What I want is I can insert same idnumber without updating the old record. Is it possible?</p>
  </blockquote>