| Issue 993: | Event loading fails while creating a JSON object from MySQL DB. | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I've modified the json-events.php to connect to a DB on localhost and create an array of fetched results . Later on in the code I've encoded the array into a JSON object, but the calendar doesn't show the events . :(
Here's my code sample.
mysql_connect("localhost","root","");
mysql_select_db(db_name); // selects my database
$res = mysql_query("select * from events");
$count = mysql_num_rows($res);
$i=0;
while($i < $count)
{
$array = mysql_fetch_array($res);
if(strcasecmp($array['start'],$array['end'])==0)
$result[$i]=array(
'id' => intval($array['id']),
'title' => $array['title'],
'start' => $array['start']
);
else
$result[$i]=array(
'id' => intval($array['id']),
'title' => $array['title'],
'start' => $array['start'],
'end' => $array['end']
);
$i++;
}
echo json_encode($result);
Structure of events table:
colname datatype format
---------------------------------
id int int
title text string
start text yyyy-mm-dd
end text yyyy-mm-dd
allday text always true
Jun 23, 2011
Project Member
#1
althaus.it
Status:
Done
|
|
| ► Sign in to add a comment |