Monthly Event Calendar for JavaScript (PHP Tutorial)

JavaScript monthly event calendar tutorial that shows how to use the widget in HTML5/PHP application.
Jul 26, 2013
monthly event calendar javascript html5

JavaScript Monthly Event Calendar Tutorial

Sample PHP Project

This tutorial shows how to use the DayPilot Monthly Event Calendar for JavaScript with PHP.

It includes a sample PHP project:

  • Monthly event calendar
  • Highlighting weekends
  • Full CSS styling
  • CSS theme support
  • Loading events from the server using AJAX calls
  • Drag and drop event creating
  • Drag and drop event moving
  • Drag and drop event resizing
  • Sample SQLite database
  • HTML5

The sample PHP project is available for download.

Fast Event Loading Example (JavaScript)

  function loadEvents() {
    DayPilot.request("backend_events.php", function(result) {
        var data = eval("(" + result.responseText + ")");
        dp.events.list = data;
        dp.update();
    });
  }

backend_events.php

<?php
require_once '_db.php';
    
$result = $db->query('SELECT * FROM events');

class Event {}
$events = array();

foreach($result as $row) {
  $e = new Event();
  $e->id = $row['id'];
  $e->text = $row['name'];
  $e->start = $row['start'];
  $e->end = $row['end'];
  $events[] = $e;
}

echo json_encode($events);

?>