title: PHP to JAVA - Database JSON
body: <p>There are plenty of examples of using database records to disable certain dates (unavailable) using JSON and AJAX however for some reason, these are done in PHP. Is there reason why it isn't done in JAVA and how can I replace the PHP file with Java for the exact same result?</p>
  
  <p><strong>checkDates.php</strong></p>
  
  <pre><code>&lt;? php
  $sql = "SELECT start from gbh_rooster_afwijkend WHERE dlnmrID = '".$_GET['dld'].
  "'";
  $res = mysql_query($sql) or die(mysql_error());
  
  $checkDates = array();
  while ($row = mysql_fetch_assoc($res)) {
  
    $checkDate['start'] = $row['start'];
  
    $checkDates[] = $checkDate;
  }
  echo json_encode($checkDates);
  
  ?&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>$.getJSON('script/php/afwijkendrooster/checkDates.php?dld='+ id, function(json){dates=json;});
  
  function checkAvailability(mydate){
      var myBadDates = dates;
  
              var $return=true;
              var $returnclass ="available";
              $checkdate = $.datepicker.formatDate('dd-mm-yy', mydate);
  
                      // start loop
              for(var x in myBadDates)
               {  
  
               $myBadDates = new Array( myBadDates[x]['start']);  
  
                 for(var i = 0; i &lt; $myBadDates.length; i++)
  
                   if($myBadDates[i] == $checkdate)
                     {
                          $return = false;
                              $returnclass= "unavailable";
                     }
                }
                            //end loop
  
              return [$return,$returnclass];
  }
  </code></pre>