First of all, here is the code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.2/fullcalendar.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.2/locale-all.min.js'></script>
<script>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
plugins: ['dayGrid', 'interaction'],
locale: 'sr-latn',
selectable: true,
selectHelper: true,
editable: true,
eventLimit: true,
eventOverlap: true,
events: './appdata/load-events.php',
select: function(start, end) {
var title = prompt('Unesite naziv događaja:');
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
calendar.fullCalendar('renderEvent', eventData, true); // stick? = true
$.ajax({
url: './appdata/add-event.php',
data: 'title=' + title + '&start=' + start.format() + '&end=' + end.format(),
type: 'POST',
dataType: 'json',
success: function(response) {}
});
}
calendar.fullCalendar('unselect');
},
});
});
as you can see I am using fullcalendar library and the version 3.10.2 since for some reason I can’t load newer ones it pops up with GET 404 error in console, anyway I need a way to make days that are occupied by the events from the database not clickable, meaning that you can’t add events to those days again, Here are the codes from php:
add-event.php
<?php
include('./connect-to-base.php');
if (isset($_POST['title']) && isset($_POST['start']) && isset($_POST['end'])) {
$title = $_POST['title'];
$start = $_POST['start'];
$end = $_POST['end'];
$sql = "INSERT INTO events(title, start, end) values('$title', '$start', '$end')";
$result = mysqli_query($conn, $sql);
echo json_encode($result);
}
and load-events.php
<?php
include('./connect-to-base.php');
$sql = "SELECT * FROM events";
$result = mysqli_query($conn, $sql);
$events = array();
while ($row = mysqli_fetch_assoc($result)) {
$title = $row['title'];
$start = $row['start'];
$end = $row['end'];
$events[] = array(
'title' => $title,
'start' => $start,
'end' => $end
);
}
echo json_encode($events);
the connect-to-base.php is just the classic connection php
I have tried using “selectConstraint” and some other things that ChatGPT reccomended like “selectAllow” but that’s for newer versions right?

