title: How to insert datepicker into the database in php
body: <p>I'm having a trouble of inserting my date &amp; time in my database. I used jquery datepicker and for the time I used a select options tag so I just need them to be inserted into the database. 
  This is my date table:</p>
  
  <p><strong>DATABASE:</strong></p>
  
  <p><code>CREATE TABLE</code>date_tbl<code>(
  </code>date<code>varchar(30) NOT NULL,
  </code>time<code>varchar(30) NOT NULL,
  </code>ordertype<code>int(10) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;</code></p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code> &lt;div class="col-md-4"&gt;
      &lt;h5 class="control-label" style="font-family:Lucida Calligraphy;margin-left: -15px"&gt;Date:&lt;/h5&gt;
      &lt;input type="text" name="datepicker" class="form-control" placeholder='Select date' id="datepicker" style="margin-left: -15px"/&gt;
      &lt;script&gt;
          $(function() {
          $('#datepicker').datepicker({
          minDate: 0,
          dateFormat: 'yy-mm-dd'
          });
          });
      &lt;/script&gt;
   &lt;/div&gt;
   &lt;div class="col-md-4"&gt;
      &lt;h5 for="inputDate" class="control-label" style="font-family:Lucida Calligraphy;margin-left: -15px"&gt;Time: &lt;/h5&gt;
      &lt;select type="text" name="time" id="time" class="form-control"&gt;
          &lt;option&gt;Select time&lt;/option&gt;
          &lt;option&gt;08:00 AM&lt;/option&gt;
          &lt;option&gt;09:00 AM&lt;/option&gt;
          &lt;option&gt;10:00 AM&lt;/option&gt;
          &lt;option&gt;11:00 AM&lt;/option&gt;
          &lt;option&gt;01:00 PM&lt;/option&gt;
          &lt;option&gt;02:00 PM&lt;/option&gt;
          &lt;option&gt;03:00 PM&lt;/option&gt;
          &lt;option&gt;04:00 PM&lt;/option&gt;
          &lt;option&gt;05:00 PM&lt;/option&gt;
       &lt;/select&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>&lt;?php 
     include('db.php');
     if(isset($_POST['reserve'])){
          $wdate = $_POST['datepicker'];
          $wtime = $_POST['time'];
  
          $wdate_array = array();
          $wtime_array = array();
  
          $insertDate=$conn-&gt;query("INSERT INTO date_tbl (date, time, ordertype) VALUES ('$wdate','$wtime',0)");
  
         $q=$conn-&gt;query("SELECT * FROM date_tbl");
  
         $dateRow=mysqli_num_rows($q);
  
             while($row=mysqli_fetch_array($q)){
                 $wdate_array[]=$row['date'];
                 $wtime_array[]=$row['time'];
             }
              if(array_intersect($wdate_array, $wtime_array)){
                  echo "&lt;p style='text-align:center;color:red;'&gt;&lt;span class='fa fa-warning'&gt;&lt;/span&gt; Date &amp; Time Invalid!&lt;/p&gt;";
              }else{
                  echo "&lt;p style='text-align:center;color:green;'&gt;&lt;b&gt;&lt;/b&gt; Date &amp; Time are available!&lt;/p&gt;";
              }
       }
  ?&gt;
  </code></pre>
  
  <p>whenever i try to reserve it will only insert once and when i try again it doesn't insert anymore.</p>