I'm retrieving data from MySql with php like this =>
while ($birthday_row = $birthday_r->fetch_row()){
$birthday_array[] = array(
'title' => $birthday_row[0],
'start' => $birthday_row[1] . "-" . $birthday_row[2]
);
}
JavaScript:
var json_obj_birthday = <?php if (isset($birthday_array)){echo json_encode($birthday_array);} ?>;
var json_obj_birthday_len = json_obj_birthday.length;
var d = new Date();
var event = [];
for (var i=0;i<json_obj_birthday_len;i++){ // adding manually year
json_obj_birthday[i].start = d.getFullYear() + "-" + json_obj_birthday[i].start;
event = {
'title' : json_obj_birthday[i].title,
'start' : json_obj_birthday[i].start
};
}
In above JavaScript code into event
array is stored only for first data , it only stores for json_obj_birthday[0]
, how can I store all information into event
array ? thanks
PS. I want that array event
be json encoded with full information
UPDATE
now I've tried like this
var events = <?php if (isset($birthday_array)){echo json_encode($birthday_array);} ?>;
var d = new Date();
for (var i = 0; i < events.length; i++){
events[i].start = d.getFullYear() + "-" + events[i].start;
}
and doesn't get desire result as well
Second Update
I need what I'm trying to do because want to pass this event
variable into jQuery full calendar, here is script =>
jQuery("#calendar").fullCalendar({ // initialize full calendar
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
events: [
event
] // here was my fault , I must to have `events: event,`
});
After tying your code guys , information into calendar doesn't inserted , That's what I mean doesn't work
PS. If someone interested more deeply what I am doing and why , pls take a look at my previous question too add birthday events into jQuery full calendar each year
event
isn't an array. – Ignacio Vazquez-Abrams Sep 6 at 19:53event = [];
If not if Multidimensional array ? – DaHaKa Sep 6 at 19:56