| Issue 1250: | How to show event from database on jsp | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I want my project use fullcalendar with jsp and can show event from database. I found other web that he talk about json but can't understanding. Plzz help me my code still begin of fullcalendar
events: [
{
title: 'Datastructure',
start: new Date(y, m, 1)
},
{
title: 'Database',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
}]
how i can retreive it from database (mysql)
Jun 11, 2012
#1
mohit.bh...@gmail.com
Dec 21, 2012
HI, I did this and work fine for me
in My view File i Have this
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
theme: true,
slotMinutes: 15,
minTime: 17,
defaultEventMinutes: 90,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
allDayDefault: false,
events: function(start, end, callback) {
$.getJSON(
//URL WHERE I GET THE DATA FOR THE EVENTS, PHP FILE
"http://localhost/BLABLA/cont_reservation/METHOD
function(result) {
callback(result);
}
);
}
});
});
</script>
Now, this is the method which I called in the URL, at the PHP File ('cont_reservation'). (I use codeigniter Framework)
function method()
{
$sql = "YOUR SQL QUERY ";
$query = $this->db->query($sql);
foreach ($query->result() as $obj) {
$arr[] = array(
'id' => $obj->id,
'title' => $obj->title,
'start' => date("c", strtotime($obj->start)),
'end' => date("c", strtotime($obj->end)),
'backgroundColor' => $obj->color_estado_cita,
'allday' => false,
'editable' => true
);
}
echo json_encode($arr);
}
I hope this helps you.
Alfonso E. Leon
Aug 14, 2013
(No comment was entered for this change.)
Status:
Invalid
|
|
| ► Sign in to add a comment |