I have a database with a date in the field start
, I would like to display only the birthday of the current month in fullcalendar
, but I have two difficulties:
-
Select only the birthdays of the current month
-
Show birthdays in the corresponding month in the current calendar year, not the original year of the field.
I currently have this code:
<?php
//Database
$data = array();
$link = mysqli_connect("localhost", "root", "", "agenda");
mysqli_set_charset($link, 'utf8');
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$query = "SELECT * FROM clientes";
if ($result = $link->query($query)) {
/* fetch object array */
while ($obj = $result->fetch_object()) {
$data[] = array(
'id' => $obj->id,
'title'=> $obj->title,
'start'=> $obj->start
);
}
/* free result set */
$result->close();
}
mysqli_close($link);
?>
<script>
$(document).ready(function() {
$('#clientes').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: '<?php echo date('Y-m-d');?>',
editable: true,
eventLimit: true, // allow "more" link when too many events
events : <?php echo json_encode($data);?>
});
});
</script>
And the view looks like this: