0

我目前正在尝试仅使用从 sql 数据库中提取的数组中保存的日期填充内联 jquery datepicker。我的代码如下。如果有人能指出如何正确解析数组以便 jQuery 函数中的“enableDays”数组填充从 sql 查询返回的数据,那将是一个很大的帮助。任何帮助将不胜感激。谢谢

<?php
// connection is set up above


mysql_connect("$host", "$username", "$password")or die("Connection to database: Failed"); 
mysql_select_db("$db_name")or die("Connection to table: Failed");

$sql="SELECT DISTINCT date FROM xcp_results WHERE zzx='TRD' ORDER BY date DESC"; 
$result=mysql_query($sql);
$array = mysql_fetch_array($result);
$count=mysql_num_rows($result);



?>





<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Calender Control Test</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>



    jQuery(function(){

    var enableDays = ["07-08-2013"];

    function enableAllTheseDays(date) {
        var sdate = $.datepicker.formatDate( 'dd-mm-yy', date)
        console.log(sdate)
        if($.inArray(sdate, enableDays) != -1) {
            return [true];
        }
        return [false];
    }

    $('#datepicker').datepicker({dateFormat: 'dd-mm-yy', beforeShowDay: enableAllTheseDays});
})


 </script>
</head>
<body>



<div id="datepicker"></div>


</body>
</html>
4

0 回答 0