我正在为旅游网站实施一个售罄功能。如果所有座位在该特定日期售罄,此功能将允许管理员从预订日历中删除一些日期。
我将这些售完日期存储在一行中的mysql数据库中并按如下方式获取它们:
<?php
$conn = mysqli_connect("localhost", "root", "");
mysqli_select_db($conn, "vendors");
$result = mysqli_query($conn , "SELECT * FROM editor_data where tour_id = 1") or die (mysqli_error ($conn));
$row = mysqli_fetch_array($result);
$checked = explode(',' , $row['soldout']);
$arrlength = count($checked);
$from = $row['fromdate'];
$to = $row['Todate'];
?>
现在禁用日期这就是我正在做的事情。但它没有用。请帮帮我!
$(function() {
$('#iDate').datepicker({
showButtonPanel: true,
dateFormat: 'yy-mm-dd',
beforeShowDay: checkAvailability
});
});
var $myBadDates = new Array('<?php
for($x = 0; $x < $arrlength; $x++) {
echo '"'; echo $checked[$x]; echo '"';
echo " , ";
}
?>');
function checkAvailability(mydate){
var $return=true;
var $returnclass ="available";
$checkdate = $.datepicker.formatDate('yy-mm-dd', mydate);
for(var i = 0; i < $myBadDates.length; i++)
{
if($myBadDates[i] == $checkdate)
{
$return = false;
$returnclass= "unavailable";
}
}
return [$return,$returnclass];
}