我需要将数据库中的事件循环到一个日历中

时间:2013-10-10 08:41:18

标签: php jquery

<? //Calendar starts ?>     
$('#calendar').fullCalendar({

            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'

            },
            editable: true,

      (<? while($row = mysql_fetch_array($fetch_results)){?>),

<? // Events start I need to loop only these events i'm getting from the database table ?>

     events: [
                {
                    id: '',
                    title:  '<?=$row[title];?>',
                    start: '<?=$row[start_time];?>',
                        end: '<?=$row[end_time];?>',

                } ,
            ]
<? // Events ends?>
(<? }?>)

            });


    });
<? //Calendar ends ?>

1 个答案:

答案 0 :(得分:0)

现在你的代码会创建多个events部分,而events应该是一个数组,所以将你的循环移到实际的events部分:

events: [
<? while($row = mysql_fetch_array($fetch_results)){?>
            {
                id: '',
                title:  '<?=$row[title];?>',
                start: '<?=$row[start_time];?>',
                    end: '<?=$row[end_time];?>',

            } ,
<? }?>
]