About jQuery fullcalendar

Asked 2 years ago, Updated 2 years ago, 51 views

We are working with fullcalendar and Mysql to create applications.

When you click the month switch button (month, month after month), you can view the event for that month. I'd like to switch and draw, but how should I implement it?

1. First View → Obtain data from December list 2. Switch the month with the button → Get a list of events for the month you switched and redraw it

I'm sorry, but I'd appreciate it if you could let me know.

php jquery mysql

2022-09-30 18:30

1 Answers

In jQuery fullCalendar, you can read events from aax by setting the events option.

$('#calendar').fullCalendar({
    events: 'myfeed.php'
});

For more information, see the Manual, but for PHP, you can return the event using the following script:

<?php
// myfeed.php

// jQuery FullCalendar passes range to GET parameter start, end in YYYY-MM-DD format by default
$start=DateTime::createFromFormat('Y-m-d', $_GET['start']);
$end = DateTime::createFromFormat('Y-m-d',$_GET['end']);

$start->setTime(0,0,0);
$end->setTime(23,59,59);

// Querying Events...
// $events = $db->query(
//     'SELECT* FROM events WHERE date>=?AND date<=?',
//     $start->format('Y-m-d H:i:s'),
//     $end->format('Y-m-d H:i:s')
// );

// ...and Output
echo json_encode(
    array(
        array('start'=>'2014-12-12', 'title'=>'Event 1'),
        array('start'=>'2014-12-22', 'title'=>'Event 2'),
    )
);


2022-09-30 18:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.