I’m using full calender and I have a few events that are all day events. Generally, my php set all 'allDay' => 'false'. Now that I noticed it adds a time on it if I do not specify a time.
I want to set all defaults false for all values, unless I specify them true.
My php fetch is as follows:
$sql = "SELECT `id`, `title`, `time`, `start`, `end`, `url`, `backgroundColor`, `textColor`, `className`,
`allDay` FROM calender WHERE length('column') > '0'";
$result = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row){
$return[]=array('id'=>$row['id'],
'title'=>$row['title'],
"allDay" =>$row['allDay'],
'start'=>$row['start'].' '.$row['time'],
'end'=>$row['end'],
'url'=>$row['url'],
'backgroundColor'=>$row['backgroundColor'],
'textColor'=>$row['textColor'],
'className' =>$row['className']);
}
$dbh = null;
header('Content-type: application/json');
echo json_encode($return);
and the jQuery function is:
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: false,
events: "json-events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(You cannot update these fields!)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
});
});
I do not know where I add the values. I have mySQL storing ‘allDay’ as true/false but it returns as a string. So I actually know how to go about coverting it before json encodes the file. or have jQuery/javascript change it after the data is being looked at.
What type is the allDay field in MySQL? If it’s an
enum('true', 'false'), that’s probably your problem. That gets converted to a string. I’ve had people do this, and it took me forever to figure out why what I thought was a boolean (or an int) was a string.Double check your database and try making it a
tinyint(1)and using 0 for false and 1 for true. PHP’s boolean true and false will get casted to the corresponding integers and you won’t have a problem using 0/1 in JavaScript.