我使用fullcalender.js来显示来自带有laravel框架的php mysql的动态数据。这只是表的第一个数据。
下面是mysql数据库中的json。
[
{
"rp_status": "Paid",
"emi_date": "08-09-2018",
},
{
"rp_status": "UnPaid",
"emi_date": "22-09-2018",
},
{
"rp_status": "UnPaid",
"emi_date": "06-10-2018",
},
]
下面是我的jquery完整日历代码。我也在使用for循环,但它只显示了数据库中的第一行。
$('#calendar').fullCalendar({
defaultView: 'month',
eventSources: [
{
events: [
@for($i = 0; $i< count($repay_info); $i++)
{
title : '{{ $repay_info[$i]["rp_status"] }}',
start : '{{date("d-m-Y", strtotime($repay_info[$i]["emi_date"]))}}',
rendering: 'background',
backgroundColor: '{{ $repay_info[$i]["rp_status"]}}',
},
@endfor
],
textColor: 'white'
}
]
});
我分享下面输出的图片以供参考。