由于某些原因,我无法在我的Fullcalendar上看到任何事件显示。
HTML
$(document).ready(function () {
$('#calendar').fullCalendar({
events: 'calendar/json-events.php'
});
});
Json-events.php
<?php
$json = array();
$request = "SELECT * FROM event ORDER BY id";
try {
$bdd = new PDO('mysql:host=Roger-PCSQLEXPRESS;dbname=calendar');
} catch(Exception $e) {
exit('Can't access the database.');
}
$result = $bdd->query($request) or die(print_r($bdd->errorInfo()));
echo json_encode($result->fetchAll(PDO::FETCH_ASSOC));
?>
所以我有一些数据在我的数据库,仍然没有显示,我想知道也许有一些问题与我的url从事件?我试着把
events: 'events.php'
仍然没有显示,那么可能是我与数据库的连接?
我的表中有4个字段:Id, title, start, end
感谢阅读!
您是否尝试过将json-events.php放在主文件夹中?下面是我的json-events.php代码。我的数据库表布局与你的不同,所以请记住这一点。注意,你必须正确命名你的字段…比如开始,结束,url,颜色,标题,描述…
<?php
require(realpath($_SERVER["DOCUMENT_ROOT"]).'/include/Database.php');
require(realpath($_SERVER["DOCUMENT_ROOT"]).'/include/Common.php');
// connect to the server
$db->connect();
$sql = "SELECT e.eventid AS 'id',
e.title,
e.description,
UNIX_TIMESTAMP(datestart) AS 'start',
UNIX_TIMESTAMP(dateend) AS 'end',
'' AS 'allDay',
CONCAT('#',c.gcalcolor) AS 'color',
CONCAT('/clubs/',c.urlname,'/events/?',e.eventid) AS 'url'
FROM events e
INNER JOIN clubevents ce ON e.eventid=ce.eventid
INNER JOIN clubs c ON ce.clubid=c.clubid";
$results = $db->fetch_array($sql);
foreach ($results as $result)
{
$rows[] = $result;
}
print json_encode($rows);
?>