Ok so i managed to figure out the php code and it is working and is outputting in the right json format when i view it in browser. Here's the code thanks to help from Starx:
<?php
include ("Includes/dbConnect.php");
$_GET['date'];
$query2 = "SELECT * FROM events";
$checkevent = mysqli_query($cxn,$query2) or die("Couldn't execute query!");
$dates = array();
while ($row2 = mysqli_fetch_array($checkevent))
{
$eventDate = $row2['eventDate'];
$eventName = $row2['eventName'];
$eventHost = $row2['host'];
$dates[$eventDate] = array('title' => $eventName, 'desc' => $eventHost);
}
echo json_encode(array("dates" => $dates));
?>
this outputs: {"dates":{"2012-03-16":{"title":"Table Quiz","desc":"MSU"},"2012-03-20":{"title":"Welcome","desc":"Me"}}}
So there has to be a problem with my jquery code. i altered it as to Starx's specifications but still nothing, anyone have any ideas??
<script type="text/javascript">
$(document).ready(function()
{
$("#ical").ical({
beforeMonth:function(date)
{
$.ajax({
type: "GET",
url: "getCalendarEvents.php",
dataType: "json",
data: "date="+date,
async: false, //stop rendering the calender until eventdates is changed.
success: json.each(function(k,v){
$.fn.ical.changeEventDates(v); //this function changes the eventdates
}
})
}
});
});
</script>
Array ( [0] => Array ( [date] => $eventDate [title] => $eventName [desc] => $eventHost ) )
, but instead, you wantArray ( [date] => $eventDate [title] => $eventName [desc] => $eventHost )
- Remove the first $dates = array();