How can I pull events from MySQL to the events-data.js page? I can pull the events using PHP from MySQL, but I don't know how to get them into the events-data.js page in the proper format.
Thanks
How can I pull events from MySQL to the events-data.js page? I can pull the events using PHP from MySQL, but I don't know how to get them into the events-data.js page in the proper format.
Thanks
Hello,
This is Definitely Possible. You will need to use a PHP File in order to achieve this. Your PHP Code will look something like this:
<?php
header('Content-Type: application/json');
// Your MySQL Related Codes
?>
var canvasEvents = {
// For Loop for Events Result from Database
'<?php echo $event_date; ?>' : '<a href="<?php echo $event_url; ?>" target=_blank><?php echo $event_title; ?></a>',
}Make sure that you add this code in a PHP file with the .php Extension and then instead of using events-data.js in the Calendar JS Codes, use this PHP File.
This will definitely work fine. Let us know if we can help you with anything else or if you find any further issues.
Have the same question, or something new?
Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.
Reply on the dashboard