0

I'm using Keith Wood's Calendars Datepicker, and I want to show a price inside a datepicker cell according to the following php query, showing a different price in each cell. How do I do this ?

$('#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>', 

        }; 
    } 
});
Manur
  • 8,436
  • 2
  • 27
  • 29
  • 2
    possible duplicate of [How to pass variables and data from PHP to JavaScript?](http://stackoverflow.com/questions/23740548/how-to-pass-variables-and-data-from-php-to-javascript) –  Aug 25 '15 at 14:52
  • You might also want to read that to understand why you can't do it the way you are trying to do it: [What is the difference between client-side and server-side programming?](http://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) –  Aug 25 '15 at 15:00
  • any idea, how to pass date.toString() to $date? – Navid Sabbaghi Aug 25 '15 at 15:10

1 Answers1

0

so I could solve this problem and now I want to show error when user selects a range date on reserve date and use date on mousehoever like this date picker

  <?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>