【发布时间】:2014-04-30 19:21:29
【问题描述】:
希望有人可以帮助我。我试图将 Fullcalendar (jQuery) 集成到我的网站。它的版本是 1.6.4。
我已经有一个数据库,其中包含我想添加到日历中的内容。在我的数据库中,原始数据具有以下名称: - 显示日期(以 2014-03-23 格式给出的事件的给定日期。应该显示该日期) - 名称(活动名称) - id(数据库中的id)
我可以看到 Fullcalendar 使用以下代码(来自文件 json-events.php)在日历中显示一些内容:
<?php
$year = date('Y');
$month = date('m');
echo json_encode(array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 222,
'title' => "Event2",
'start' => "$year-$month-20",
'end' => "$year-$month-22",
'url' => "http://yahoo.com/"
)
));
?>
我在下面用我自己的代码替换了上面的代码。我已连接到数据库,但 Fullcalendar 中没有显示任何内容
<?php
// Create connection
$con=mysqli_connect("localhost","*****","*****","*****");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
session_start();
$result = mysql_query("SELECT id, name, displaydate AS displaydate FROM caledar");
mysql_close();
$events = array();
while ($row=mysql_fetch_array($result)){
$id = $row['id'];
$title = $row['name'];
$start = $row['displaydate'];
$events = array(
'id' => "$id",
'name' => "$title",
'displaydate' => "$start"
);
}
echo json_encode($events);
?>
有人可以建议或看看我做错了什么吗?
【问题讨论】:
标签: jquery database fullcalendar