In my PHP i have the following PDO query:
$findEventStartdates = $pdo->prepare('SELECT startdate FROM calendar WHERE username=?');
//execute query with variables
$findEventStartdates->execute([$username]);
($eventStartdates = $findEventStartdates->fetchAll(PDO::FETCH_COLUMN));
If i print that query i get the following results
Array ( [0] => 14 april 2017 [1] => 25 april 2017 [2] => 1 april 2017).
My question is, how can i use this array to then highlight those dates in the datepicker. I've looked for ages on how to turn that array into variables in jquery and then highlight those days in the datepicker but can't seem to find it anywhere.
Thanks for any help.
I worked this out. After you perform the PDO you need to have some inline javascript that basically turns the array into the jquery variable. from there you can use beforeShowDay to pick up that variable and highlight the days:
$findEventStartdates = $pdo->prepare('SELECT startdate FROM calendar WHERE username=?');
//execute query with variables
$findEventStartdates->execute([$username]);
($eventStartdates = $findEventStartdates->fetchAll(PDO::FETCH_COLUMN));
?>
<script type="text/javascript">
//Assign php generated json to JavaScript variable
var event = <?php echo json_encode($eventStartdates); ?>;
</script>
<?php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.