fullcalendar事件无效

时间:2013-03-06 07:32:27

标签: php javascript json fullcalendar

我正在使用fullcalendar显示事件,我使用JSON作为事件,并将json对象形成另一个页面,但是当我遇到问题时,我得到了这个500 Internal Server Error我在stackoverflow中发现了一个queston并使用了他们的代码
FullCalendar not displaying time from JSON events
这是我的Javascript代码:

  $(document).ready(function() {

        $('#calendar').fullCalendar({                                 
            editable: false,
           events:'/json.php'
        });
    });

</script>

PHP代码:

$sql="
SELECT
    t.trans_id
    , r.res_name
    , l.location_name
    , to_char( t.trans_date, 'mm/dd/yyyy' )
    , s.ts_from
    , s.ts_to
    , t.booked_units
    , t.max_value
    , t.remaining
FROM
    tsm_transaction_tbl t
    , tsm_location_tbl l
    , tsm_resource_tbl r
    , tsm_timeslot_tbl s
WHERE
    t.location_id = l.location_id
    AND t.resource_id = r.res_id
    AND t.ts_id = s.ts_id
";

$parse=oci_parse($conn,$sql);
oci_execute($parse);
$events = array();
while($row=oci_fetch_array($parse))
{
    $start = $row[3];
    $end = $row[3];
    $title = $row[1];
    $eventsArray['id'] =  $row[0];
    $eventsArray['title'] = $title;
    $eventsArray['start'] = $start . " " . $row[4];
    $eventsArray['end'] = $end;
    $eventsArray['allDay'] = false;
    $events[] = $eventsArray;
}
oci_close($conn);
echo json_encode($events);

1 个答案:

答案 0 :(得分:0)

问题是json_encode然后我使用Zend_Json::encode它是生成JSON对象的Zend类

<?php
require_once('Json.php');

$sql="select t.trans_id,r.res_name,l.location_name,to_char(t.trans_date,'mm/dd/yyyy'),s.ts_from,s.ts_to,t.booked_units,t.max_value,t.remaining
from tsm_transaction_tbl t,tsm_location_tbl l,tsm_resource_tbl r,tsm_timeslot_tbl s
where t.location_id=l.location_id and t.resource_id=r.res_id and t.ts_id=s.ts_id";
$parse=oci_parse($conn,$sql);
oci_execute($parse);
$events = array();
while($row=oci_fetch_array($parse))
{
    $start = $row[3];
    $end = $row[3];
    $title = $row[1];

    $eventsArray['id'] =  $row[0];
    $eventsArray['title'] = $title;
    $eventsArray['start'] = $start." ".$row[4].":00:00";
    $eventsArray['end'] = $end." ".$row[5].":00:00";
    $eventsArray['allDay'] = false;
    $eventsArray['description']="Timeslot: ".$row[4]."-".$row[5]."<br> Location: ".$row[2]."<br> Max value: ".$row[7]."<br>Booked units: ".$row[6]."<br> Remaining: ".$row[8];
    $events[] = $eventsArray;
}
oci_close($conn);

echo Zend_Json::encode($events);

?>