title: jQuery datepicker, disable dates from MYSQL
body: <p>I have a list of dates stored in a MYSQL table, the idea is if the following field has valued 'completed' the row's date is unselectable in the jQueryUI datepicker. The dates are stored in the format YYYY-MM-DD.. how would I go about loading these 'completed' dates into a PHP array in a format for the datepicker to understand and disable them? JSON would be the obvious answer, I've spent the last couple of weeks getting to grips with it. Any example code of the jquery / php code would be greatly appreciated.</p>
  
  <p>Many thanks in advance.</p>
  
  <p>[ I have done research around the subject but it is not particularly well documented.. I've already got the datepicker showing valid days in a week. The jqueryUI datepicker seems to be able to do everything except make me a cup of tea. ]</p>
  
  <p>EDIT: So I've managed to feed the array of dates with 'final' status through with JSON, I thought i'd provide the code if it helps anyone:</p>
  
  <pre><code>    &lt;?php
  
      //connect to local db
      include('functions.php');
      connectLocal($localcon);
  
      //locate rows with status set to final
      $result = mysql_query("SELECT sendDate FROM my_table WHERE status='final'");
  
      // return corresponding dates as json array
      $i=0;
      while($row = mysql_fetch_array($result))
      {
          $confirmedSends[$i] = array ( "sendDate" =&gt; $row['sendDate']);
          $i++;
      }
      header('Content-type: application/json');
      $jsonConfirmedSends =  json_encode($confirmedSends); 
      echo $jsonConfirmedSends;
  ?&gt;
  </code></pre>
  
  <p>This can retrieved with json in the form of a list of dates. The alert box pops up once for each date. About to get to work on presenting these to my datepicker array.</p>
  
  <pre><code>$.getJSON("get-disabled-dates.php",
  function(data){
       $.each(data, function(index, completed) {
          alert(completed.sendDate);
      });
  });
  </code></pre>