title: Jquery Ajax - check date and time availability
body: <p>I have a booking form where I want to live check for availability. I managed to get this working just for checking if date is available, but having trouble also incorporating time into it. </p>
  
  <p>This is how I do the check in Jquery / Ajax:</p>
  
  <pre><code> $(document).ready(function(){
      $("#time_select_2_hour").change(function(){
      $("#availability_1").html("&lt;img src='ajax-loader.gif' /&gt; checking...");
  
  
      var date1=$("#date1").val();
      var time_select_2_hour=$("#time_select_2_hour").val();
  
        $.ajax({
              type:"post",
              url:"check.php",
              data:"date1="+date1,
              data:"time_select_2_hour="+time_select_2_hour,
                  success:function(data){
                  if(data==0){
                      $("#availability_1").html("&lt;img src='tick.png' /&gt; Tour  is available!");
                  }
                  else{
                      $("#availability_1").html("&lt;img src='cross.png' /&gt; Tour is fully booked, please choose another date or tour time.");
                  }
              }
           });
  
      });
  
   });
  </code></pre>
  
  <p>And this is the check.php</p>
  
  <pre><code>  $date1=$_POST["date1"];
    $time=$_POST["time_select_2_hour"];
  
    $query=mysql_query("SELECT * from bookings where date1='$date1' AND time ='$time'");
  
    $find=mysql_num_rows($query);
  
    echo $find;
  </code></pre>
  
  <p>It's not throwing any errors, it just always says "Available" even if that combinations is already booked.</p>