mercredi 2 mars 2016

how to get values from db and insert them to full calendar 2.6.1 events array

my code is as follows.

<?php $ta=array();$da=array();$i=0;?>
@foreach($events as $ev)
    <?php
    $ta[$i]=$ev->title;
    $da[$i]=$ev->eventDate;
    $i++;
    ?>

@endforeach

<script>
    var t=<?php echo json_encode($ta)?>;
    var d=<?php echo json_encode($da)?>;

$(document).ready(function() {


                $('#calendar').fullCalendar({

                    //defaultDate: '2016-03-12',
                    editable: true,
                    eventLimit: true, // allow "more" link when too many events


                    //$r=$ev->title;

                    for(var j=0;j<d.length;j++)
                    {


                        events: [{
                                title: t[j],
                                start: d[j]
                            }
                        ]


                    }



                });

    });

</script>

But nothing displayed. Please can anybody help me? I want to retrieve all the title and eventDate from the db and view in the calendar. The var t and d contains the all the data of $ta and $da arrays. I just wanted to assign them to events array title and start keywords.There are some red marks indicate that for loop is going to be wrong.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire