Trying to create calendar events using json-events.php but only works if
there is only one record. I must be going about this the wrong way.
Thanks for any help.
events: "json-events.php", ( This is my call from the HTML )
<?php
$year = date('Y');
$month = date('m');
$dbhost = 'localhost';
$dbuser = 'kw4691';
$dbpass = '33kiko';
$dbname = 'AB_CALENDER';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');
mysql_select_db($dbname);
$query_header = "select id,bridge,start_time,end_time from
calender_datas";
$result_header= mysql_query($query_header,$conn);
while ($row1=@mysql_fetch_array($result_header, MYSQL_NUM)) {
echo json_encode(array(
array(
'id' => $row1[0],
'title' => "$row1[1]",
'start' => "$row1[2]",
'end' => "$row1[3]",
'url' => "http://yahoo.com/"
)
));
}
?>
you need to accumulate all the events into an array, and json_encode the entire array at the very end. something like this: $events = array() while ($row1=@mysql_fetch_array($result_header, MYSQL_NUM)) { $events[] = array( 'id' => $row1[0], 'title' => "$row1[1]", 'start' => "$row1[2]", 'end' => "$row1[3]", 'url' => "http://yahoo.com/" ); } echo json_encode($events);