Issue 1250: How to show event from database on jsp
Status:  Invalid
Owner: ----
Closed:  Aug 2013
Reported by Apichaya...@gmail.com, Jan 22, 2012
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
I also want to import events from a table in Database. I can do it by AJAX call and create an event array but where should i insert it so that i can get the start date and end date of present month view...
Please reply..
Dec 21, 2012
#2 alfonsoe...@gmail.com
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
Project Member #3 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Invalid