title: Disable jquery datepicker calendar days, based on ajax php mysql table
body: <p>I already have a  that works OK when I click on datepicker, with "beforeShowDay" function, I trigger a $.getJSON PHP procedure, that reads a MySQL table, create an array, and with another function, I disabled the days on the dataepicker calendar I want. This works ok, only for one calendar.  Now need I need to disble datepickers days, on multiple calendars that are generated on a PHP/MySql list. Here is my code, hope you understand me and give me a help !</p>
  
  <pre><code>&lt;script&gt;
     var unavailableDates = [];
     $(document).ready(function(){
      var myTour = "&lt;?php echo $tourid ;?&gt;";
      $.getJSON('closed_dates.php',{ 
           tourid: myTour
      },
       function(data) {
          unavailableDates = data;
     }); });
  
  function unavailable(date) {
    ymd = date.getFullYear() + "-" + ("0"+(date.getMonth()+1)).slice(-2) + "-" +  ("0"+date.getDate()).slice(-2);
  day = new Date(ymd).getDay();
  if ($.inArray(ymd, unavailableDates) &lt; 0) {
      return [true, "enabled", "Book Now"];
  } else {
      return [false,"disabled","Sold Out"];
  }
  }  
  
  
  
  enter code here$(function() {
  
    $('.iDate').datepicker({
        dateFormat: 'dd-mm-yy', 
        minDate: 0, 
        beforeShowDay: unavailable,
  
     });});&lt;/script&gt;
  </code></pre>
  
  <p>This code works if only have one calendar, but I need to be able to disabled datepickers calendar day from a list, this is my PHP code</p>
  
  <pre><code>$query_tours = "Select * from tours where status ='A' and featured = 'Y' order by rand() limit 0,20" ;
  $result_tours = mysql_query($query_tours);
  while($row=mysql_fetch_array($result_tours )) {
  $tourid   = $row['recid'];
  $tit_ing  = $row['tit_ing'];
  (some html/css code here .....)
  print "&lt;input type='number' name='adults'&gt;";
  print "&lt;input type='number' name='children'&gt;";
  print "&lt;input type='text' name='tourdate' class='iDate' id='date$tourid'&gt;";
  }
  </code></pre>
  
  <p>So I do  not know how to pass the id value from php (list) and send as the value of 'myTour' on the  $.getJSON, for each datepicker calendar.</p>
  
  <p>Hope, somebody understand me, best regards,</p>