[英]fullcalendar.io render events with PHP/MySQL?
I'm trying to implement this calendar into my site using a "while" command with PHP. 我正在尝试通过PHP的“ while”命令将此日历实施到我的网站中。 I dont know JSON or AJAX so not sure thats an option for me.
我不知道JSON或AJAX,所以不确定这是否是我的选择。 i have this code right now but it renders a calendar FOR EACH EVENT and not 1 calendar with all events on it.
我现在有此代码,但它为每个事件提供一个日历,而不是其中包含所有事件的1个日历。 I understand why, because i'm looping the whole calendar code, but is there a way to just loop the events?
我知道为什么,因为我要循环整个日历代码,但是有没有办法循环事件呢?
<div class="widget">
<div class="navbar">
<div class="navbar-inner"><h6>Calendar</h6></div>
</div>
<div id="calendar" class="well"></div>
</div>
<?
$query = "SELECT * FROM tevents";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
$calname = $row['Event_Title'];
$caldate = $row['Start_Date'];
$calnotes = $row['Event_Details'];
$caltime = $row['Event_Time'];
?>
<script>
//===== Calendar =====//
$('#calendar').fullCalendar({
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,
events: [
{
title: '<?=$calname?>',
start: '<?=$caldate?>'
},
]
);
</script>
Create a json for events. 为事件创建一个json。
$events = [];
while($row = mysql_fetch_array($result)){
$events[] = ['title' => $row['Event_Title'], 'start' => $row['Start_Date']];
}
And then, create the calendar with the $events
然后,使用
$events
创建日历
$('#calendar').fullCalendar({
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,
events: <?= json_encode($events) ?>
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.