Populating events in full calender javascript from the database

自闭症网瘾萝莉.ら 提交于 2019-11-29 17:29:24

Build an array in your php and format it as json in your javascript. Pass the formatted json to the event property like this :

events: buildRecordsToJson(calendar_records)


function buildRecordsToJson(calendar_records){
    var employees = [];
    for(var record in calendar_records) {

        var item = calendar_records[record];

        employees.push({ 
            "title"  : "Case # " + item.case_number,
            "record" : item.id,
            "start"  : item.case_due_date 
        });
    }

    return employees;
}

Edit :

Assuming this is your result

$result=mysqli_query($con,$sql);

Iterate the result sets from your database and push it to the main array.

$list = array();
while ($row = mysqli_fetch_row($result))
{ 
    $entry = array();
    $entry["booking_date"] = $row["booking_date"];
    $entry["booking_start_time"] = $row["booking_start_time"];
    array_push($list,$entry);
}
mysqli_free_result($result);

Return $list array to your javascript and feed it to your calendar events after you formatted it to json (might not be necessary).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!