Integrating jQuery fullcalendar into PHP website

前端 未结 11 864
夕颜
夕颜 2021-02-01 09:28

I would like to integrate the jQuery fullcalendar into my PHP website, but I don\'t know how to handle the event and how to use the JSON data from MySQL.

Any advice wou

11条回答
  •  情歌与酒
    2021-02-01 10:25

    I had the same problem and just found out how to make it work. Here is the code that you should use in your php file:

    $query = "select * from events where accountNo = '$accountNo'";
    $res = mysql_query($query) or die(mysql_error());
    $events = array();
    while ($row = mysql_fetch_assoc($res)) {
        $start = "2010-01-08T08:30"";//Here you have to format data from DB like this.
        $end = "2010-01-08T08:30";//This format works fine
        $title = $row['firstName']." ".$row['lastName'];
        $eventsArray['id'] =  $row['id'];
        $eventsArray['title'] = $title;
        $eventsArray['start'] = $start;
        $eventsArray['end'] = $end;
        $eventsArray['allDay'] = "";
        $events[] = $eventsArray;
    }
    
    
    echo json_encode($events);
    

    I hope it helps :).

提交回复
热议问题