如何使用从mysql服务器(phpmyAdmin)检索的数组在FullCalendar中添加事件?
在此之前,我非常感谢在这方面得到的任何帮助。如果我的错误显而易见,我也要道歉。我的问题是,我似乎找不到如何显示数组中的所有元素来填充事件的方法如何使用从mysql服务器(phpmyAdmin)检索的数组在FullCalendar中添加事件?,php,fullcalendar,Php,Fullcalendar,在此之前,我非常感谢在这方面得到的任何帮助。如果我的错误显而易见,我也要道歉。我的问题是,我似乎找不到如何显示数组中的所有元素来填充事件的方法 for(var i = 0;i < count;i++) { // these are the arrays that contain my events var primaryAsset = primaryAssets[i]; var rele
for(var i = 0;i < count;i++)
{
// these are the arrays that contain my events
var primaryAsset = primaryAssets[i];
var release_Date = releaseDates[i];
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
weekMode: 'liquid',
weekends: true,
events: [
{
title: primaryAsset,
start: release_Date,
end: release_Date
}
]
});
}
for(变量i=0;i
请先创建事件数组,然后像日历一样传递到完整日历中
var evt = [
{
title : 'event1',
start : '2014-01-01'
},
{
title : 'event2',
start : '2014-01-05',
end : '2014-01-07'
},
{
title : 'event3',
start : '2014-01-09T12:30:00',
allDay : false
}
];
然后加入全压延机
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
weekMode: 'liquid',
weekends: true,
events: evt
});
这是我从php文件获取json数据的脚本。这可能对你有用
<script>
$('#calendar').fullCalendar(
{
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events:
{ // Render the events in the calendar
url: 'calendarData.php', // Get the URL of the json feed
error: function()
{
alert('There Was An Error While Fetching Events Or The Events Are Not Found!');
}
}
});
</script>
以下是我采取的步骤,这些步骤非常顺利:
1.使用fullCalendar文档中的基本代码加载日历:
<script>
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
})
});
</script>
$('#calendar').fullCalendar({
events: [
{
title : 'event1',
start : '2010-01-01'
},
{
title : 'event2',
start : '2010-01-05',
end : '2010-01-07'
},
{
title : 'event3',
start : '2010-01-09T12:30:00',
allDay : false // will make the time show
}
]
});
<script>
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
})
});
</script>
$('#calendar').fullCalendar({
events: [
{
title : 'event1',
start : '2010-01-01'
},
{
title : 'event2',
start : '2010-01-05',
end : '2010-01-07'
},
{
title : 'event3',
start : '2010-01-09T12:30:00',
allDay : false // will make the time show
}
]
});
<script>
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
events: [
//start if
<?php
if ( have_posts() ) :
//start a while statement
while ( have_posts() ) :
the_post();
$content_types = get_the_terms( $post_id, $taxonomy_categories );
$tag_link = get_field('tag_link');
$tag_host = parse_url($tag_link);
$tag_page = $tag_host['scheme'] . '://' . $tag_host['host'];
?>
{
title : '<?php the_title();?>',
start : '<?php the_field('date');?>'
//only need one item in the array, because with the while loop, this will repeat until all the posts are added.
},
<?php
endwhile;
endif;
?>
]
})
});
$(文档).ready(函数(){
//页面现在已准备就绪,请初始化日历。。。
$(“#日历”).fullCalendar({
//把你的选择和回电放在这里
活动:[
//如果开始
{
标题:“”,
开始:“”
//数组中只需要一项,因为使用while循环,这将重复,直到添加所有帖子。
},
]
})
});
很好,先生。先生,我该怎么做?我的意思是,没有在变量中逐一列举事件。我猜是使用for循环。您可以使用events.push而不是在calendarData.php中列出事件吗?因为我确实想显示包含我的事件的for循环中的数据。$return_array=array()//[进行循环并将数据存储在$return\u array]array\u push($return\u array,$event\u array)//[循环完成后]echo json_encode($return_数组);您不应该在$('#calendar').fullCalendar({})上循环;只需尝试从json事件获取事件:{url:'calendarData.php'}