JQuery Full Calendar を使用して、mysql localhost からの JSON フィードの結果を表示しています。最初は を使用して Calendar 関数から更新されますが、POST メソッドと送信ボタンを使用してフォームの送信ボタンからevents: "json-events.php",
も実行しようとしています。json-events.php
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",
)
));
}
?>
何かアドバイス?- ご協力ありがとうございます