Good afternoon friends, how do I display only the names of the events by the month, not the year as shown in the code below. Example, has 04 user in month 09.
<?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>
This is the code of the second block of the same result.
<?php
//Database
$data = array();
$link = mysqli_connect("localhost", "root", "", "agenda");
mysqli_set_charset($link, 'utf8');
$month = date('n');
$year = date('Y');
$query = "SELECT * FROM clientes WHERE MONTH(`start`) = $month AND YEAR(`start`) = $year";
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);
?>
If the code is so, he warns "Invalid Data":
$month = date('n');
$year = date('Y');
if (is_int($month) && is_int($year)) {
$query = "SELECT * FROM clientes WHERE MONTH(`start`) = $month AND YEAR(`start`) = $year";
} else {
die ('Invalid data');
}