| Issue 165: | Problem of event displaying and handling | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Hello, I want to integrate fullcalendar into php website. But i can't display it with my code. Can anyone correct it or give me a clue? calendar.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <link rel='stylesheet' type='text/css' href='../../../plugins/fullcalendar-1.4/examples/redmond/theme.css' /> <link rel='stylesheet' type='text/css' href='../../../plugins/fullcalendar-1.4/fullcalendar.css' /> <script type='text/javascript' src='../../../plugins/fullcalendar-1.4/jquery/jquery.js'></script> <script type='text/javascript' src='../../../plugins/fullcalendar-1.4/jquery/ui.core.js'></script> <script type='text/javascript' src='../../../plugins/fullcalendar-1.4/jquery/ui.draggable.js'></script> <script type='text/javascript' src='../../../plugins/fullcalendar-1.4/jquery/ui.resizable.js'></script> <script type='text/javascript' src='../../../plugins/fullcalendar-1.4/fullcalendar.min.js'></script> <script type='text/javascript'> $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); $('#calendar').fullCalendar({ theme: true, draggable: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: true, /*events: "json_events.php",*/ events: function(start, end, callback){ $.getJSON("json_events.php", { start: start.getTime(), end: end.getTime() }, function(result){ for(var i=0; i<result.length; i++){ var row = result[i]; } $('#calendar').fullCalendar('addEvent', {id:arr[0], title:arr[1], start:arr[2], end:arr[3]} ); //format the result into an array of calevents //then pass the calevent array to the callback //callback(calevents); } ); }, eventClick: function(event){ }, eventDrop: function(event, daydelta, minutedelta) { alert(event.title + ' was moved ' + daydelta + ' days\n' + minutedelta + ' minutes\n'+ '(should probably update your database)'); }, dayClick: function(dayDate){ $('#dialog').dialog('open'); var date, month, year; date = dayDate.getDate(); month = dayDate.getMonth()+1; year = dayDate.getFullYear(); dayDate = year + "-" + month + "-" + date; }, loading: function(bool) { if (bool) $('#loading').show(); else $('#loading').hide(); }, }); }); function removeEvent(id){ $('#calendar').fullCalendar('removeEvents', id); } function updateEvent(id, title){ var event = $('#calendar').fullCalendar('clientEvents', id); event.title = title; $('#calendar').fullCalendar('updateEvent', event); } </script> <style type='text/css'> body { margin-top: 40px; text-align: center; font-size: 13px; font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif; } #calendar { width: 900px; margin: 0 auto; } </style> </head> <body> <div id='calendar'></div> </body> </html> json_events.php: <?php require("../../../connect/config.php"); $link = mysql_connect("$server","$user","$password") or die(mysql_error()); mysql_select_db($db); $query = "SELECT id,title,start, end FROM events"; $result = mysql_query($query) or die(mysql_error()); $arr = array(); while($row = mysql_fetch_assoc($result)){ $arr[] = $row; } echo json_encode($arr); ?> Thanks very much for your response.
Dec 20, 2009
closing the issue, but respond to the thread if any problems
Status:
Done
Aug 3, 2010
Could you please provide me code how to do for that above using already given events Thanks |
|
| ► Sign in to add a comment |
i can't debug this b/c i can't run the php script locally, but i've looked your script over a bit. you should use the line: events: "json_events.php", instead of your custom events function. it is more straightforward and less error prone. questions i have for you: - is the calendar (minus the events) correctly displaying? - use firebug and look to see if json_events.php is returning the correct json output. is it throwing an error? is it blank? if so, its a problem with your php script.