douwen4178 2015-01-02 17:51
浏览 122

fullcalendar数据未显示

I am very new to javascript and json. I am trying to display the events stored in my database into a calender. But its not getting displayed.

This is my json-events.php

 <?php

include("connect.php");
    $year = date('Y');
    $month = date('m');

$command = "SELECT * FROM planner";

$result = mysql_query($command) or die (mysql_error());
$bookings = array();
while ($row = mysql_fetch_array($result)) {
echo "hi";

    $start = date("Y-m-d", strtotime($row['from_time']));
    $end = date("Y-m-d", strtotime($row['to_time']));

    $id =  $row['plan_id'];
    //$eventsArray['plan_id'] =  (int)trim($myid);  
    //$eventsArray['title'] = $row['title'];  
    $title = $row['purpose']; 
    //$title = $row['title']; 
    //echo $title;
    //$eventsArray['company'] = $title; 
    //$eventsArray['from_time'] = $start;
    //$eventsArray['to_time'] = $start;
    $url = "edit_calendar.php?calendarid=".$row['plan_id'];
    // $eventsArray['end'] = $end;
    // $eventsArray['allDay'] = false;
   // $events[] = $eventsArray;

  $bookings = array(
    'id' => $id, 
    'title' => $title, 
    'start' => $start, 
    'end' => $end,
    'url' => $url
    );




echo json_encode($bookings);}



?>

and here i am linking that in calendar.js

jsonEvents: function() {
            if($('#calendar_json').length) {
                $('#calendar_json').fullCalendar({
                    header: {
                        left: 'month,agendaWeek,agendaDay',
                        center: 'title',
                        right: 'prev,next'
                    },
                    buttonText: {
                        prev: '<i class="icon-chevron-left icon-white cal_prev" />',
                        next: '<i class="icon-chevron-right icon-white cal_next" />'
                    },
                    editable: true,
                    firstDay: 1, // 0 - Sunday, 1 - Monday
                    events: "json-events.php",
                    eventDrop: function(event, delta) {
                        alert(event.title + ' was moved ' + delta + ' days
' +
                            '(should probably update your database)');
                    }
                });
            }

and in my dashboard.php page

 <div class="w-box w-box-green">
                        <div class="w-box-header"></div>
                        <div class="w-box-content">
                            <div id='calendar_json'></div>
                        </div>
                        <div class="w-box-footer">
                            <p class="f-text">JSON events fetched from a script</p>
                        </div>
                    </div>

But it just displays a calender not the data from database.

Can somebody plz suggest

When i echoed json-events, i get proper output

{"id":"3","title":"sdfsfsd dsdsbfb","start":"2015-01-05","end":"2015-01-14","url":"edit_calendar.php?calendarid=3"}

But in calender nothing is getting displayed

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?