我正在使用 JQuery Full Calendar 来显示来自我的 mysql localhost 的 JSON 提要的结果。最初它使用 更新日历功能events: "json-events.php",
,但我也尝试json-events.php
使用 POST 方法和提交按钮从表单上的提交按钮运行。虽然 JSON 提要效果很好,但我只能得到结果的 ECHO,并且无法返回 index.php 以在日历上显示结果。json-events.php 的代码...
<?php
$year = date('Y');
$month = date('m');
$day = date('d');
$link = mysql_connect('localhost','root','');
if (!$link) { die('Could not connect: ' . mysql_error()); }
mysql_select_db('jauntUK');
$latevent = $row['Lat'];
$lngevent = $row['Long'];
$tgtlat = $_POST['searchlat'];
$tgtlatstring = number_format($tgtlat, 16, '.', '');
$tgtlng = $_POST['searchlong'];
$tgtlngstring = number_format($tgtlng, 16, '.', '');
if($_POST) {
$result = mysql_query("SELECT *, ( 3959 * acos( cos( radians( `Lat` ) ) * cos( radians(" . $tgtlatstring . ") ) * cos( radians(" . $tgtlngstring . ") - radians( `Long` ) ) + sin( radians( `Lat` ) ) * sin( radians(" . $tgtlatstring . ") ) ) ) AS distance FROM EventData HAVING distance < 5")
or die (mysql_error());
// Initializes a container array for all of the calendar events
$jsonArray = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
var_dump($row);
$eventtitle = $row['Title'];
$eventdate = $row['StartDate'];
$eventend = $row['EndDate'];
$eventallday = $row['FullDay'];
$eventURL = $row['URL'];
$Description = $row['Description'];
$Address1 = $row['Address1'];
$Address2 = $row['Address2'];
$Address3 = $row['Address3'];
$Address4 = $row['Address4'];
$PostCode = $row['PostCode'];
$Admission = $row['Admission'];
// Stores each database record to an array
$buildjson = array('title' => "$eventtitle", 'start' => "$eventdate", 'end' => "$eventend", 'allday' => "$eventallday", 'eventURL' => "$URL", 'description' => "$Description", 'Address1' => "$Address1", 'Address2' => "$Address2", 'Address3' => "$Address3", 'Address4' => "$Address4", 'PostCode' => "$PostCode", 'Admission' => "$Admission");
// Adds each array into the container array
array_push($jsonArray, $buildjson);
}
// Output the json formatted data so that the jQuery call can read it
echo json_encode($jsonArray);
header('location: index.php');
} else {
echo json_encode(array(
array(
'id' => 001,
'title' => "Search for events near you",
'start' => "$year-$month-$day",
)
));
}
?>
有什么建议吗?- 在此先感谢您的帮助