将价格添加到单元格datepicker并显示

时间:2015-08-25 14:42:24

标签: php jquery datepicker

我正在使用Keith Wood's Calendars Datepicker,我想根据以下php查询在datepicker单元格中显示价格,在每个单元格中显示不同的价格。我该怎么做?

$('#popupDatepicker').calendarsPicker({

    onDate: function(date) { 
        return {content: date.day() + '<br><sub>' +
            <?php  
            $PropertyNumber=53;
            $Date= 'date.toString()';

            $res2 = $dbh->prepare("select * from property_price where PropertyNumber=:PropertyNumber and Date=:Date  ");
            $res2->execute(array(':PropertyNumber'=>$PropertyNumber,':Date'=>$Date));
            $row = $res2->fetch(PDO::FETCH_ASSOC);
            if ($res2 ) {
                echo $row['Price'] ;
            }

            ?>

            + '</sub>', 

        }; 
    } 
});

1 个答案:

答案 0 :(得分:0)

所以我可以解决这个问题,现在我想在用户选择保留日期的范围日期并在鼠标上使用日期时显示错误,例如this日期选择器

  <?php  
$PropertyNumber=53;

        $res2 = $dbh->prepare("select * from property_price where      PropertyNumber=:PropertyNumber   ");
          $res2->execute(array(':PropertyNumber'=>$PropertyNumber));
while ( $row = $res2->fetch(PDO::FETCH_ASSOC)) {
$myVarValue[]=$row;
};
echo json_encode($myVarValue);




                ?>

    <script>
    var pausecontent = <?php echo json_encode($myVarValue); ?>;


  $(function() {
    var g=<?php echo json_encode($myVarValue); ?>;
  $('#popupDatepicker').calendarsPicker({                rangeSelect:true,minDate:0,changeMonth:false,

    onDate: function(date) { 
    for (var i = pausecontent.length - 1; i >= 0; i--) {

    if (date.toString()==pausecontent[i].Date ) {
    return {content: date.day() + '<br><sub>' + 
      pausecontent[i].Price + '$</sub>',
      dateClass: 'showDoY' ,

        }; 
}}




       return {content: date.day() + '<br><sub>' + 
        0 + '$</sub>', 
        dateClass: 'showDoY'}; 


 },





});
});


</script>