How to display JSON data in events array in FullCalendar Scheduler Plugin

181 Views Asked by At

As shown, I used url to call the data to be displayed on calendar. But it's not working.

resources: [
        { id: 'a', title: 'Company' },
        { id: 'b', title: 'Activity'},
        { id: 'c', title: 'Driver', eventColor: 'orange' },
        { id: 'd', title: 'Summon', eventColor: 'red' }
      ],
      events:[
        {
          resourceId: 'a', 
          url:'comp.php',
          start: '2022-11-06T00:00:00', 
          end: '2023-11-08T23:00:00',
          color: 'yellow'
        },
        { id: '2', 
          resourceId: 'b', 
          url: 'activity.php' ,
          start: '2022-11-06T02:00:00', 
          end: '2022-11-08T018:00:00',
          color: 'pink'
        },

This is the php page where I used JSON to fetch data from db.

<?php

include "db.php";
          
$data = array();
            $sql = "SELECT * FROM company";
            $stmt = $mysqli_conn->prepare($sql);
            $stmt->execute();

            $result = $stmt->get_result();
            
            foreach($result as $row)
            {
            $data[] = array(
            "id"   => $row["id"],
            "title"   => $row["comp_name"]
            );
            }

            echo json_encode($data);

            $stmt->close();

?>

This is the output. I want to display the name of company from database on the blue timeline. How do I do that? enter image description here

It leads to new page after I clicked on the blue timeline (company resources)

enter image description here

0

There are 0 best solutions below