次の例では、MySql テーブルを読み取る php スクリプトを json 経由で呼び出し、$myBadDates を無効にして配列を返す方法を知る必要があります。
$(function() {
$( "#pickdate" ).datepicker({
dateFormat: 'dd MM yy',
beforeShowDay: checkAvailability
});
})
var $myBadDates = new Array("10 October 2010","21 October 2010","12 November 2010");
function checkAvailability(mydate){
var $return=true;
var $returnclass ="available";
$checkdate = $.datepicker.formatDate('dd MM yy', mydate);
for(var i = 0; i < $myBadDates.length; i++)
{
if($myBadDates[i] == $checkdate)
{
$return = false;
$returnclass= "unavailable";
}
}
return [$return,$returnclass];
}
ここに私のphpスクリプトがあります
:
include 'panel/db.php';
$dates_closed = array();
/// Query Dates Closed ///
$query = "SELECT dates from closed_dates order by dates ";
$result = mysql_query($query);
while($row=mysql_fetch_array($result)) {
$days = $row['dates'];
array_push($date_closed,$days);
}
echo json_encode($date_closed);
?>