У меня есть календарь и следующий код:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.css' rel='stylesheet' />
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/
bootstrap.min.css'>
<link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.print.min.css' rel='stylesheet' media='print' />
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/moment.min.js'></script>
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/jquery.min.js'></script>
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min
.js'></script>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month'
},
defaultDate: new Date(),
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true,
droppable: true, // allow "more" link when too many events
dayClick: function(date, jsEvent, view) {
$("#successModal").modal("show");
$("#eventDate").val(date.format());
},
events: <?php echo json_encode($myArray); ?> });
});
</script>
<style>
body {
margin: 40px 10px;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#calendar {
max-width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
<div class="modal fade" id="successModal" role="dialog" aria-labelledby="successModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Apply Leave</h4>
</div>
<div class="modal-body">
<form action="#" method="post">
<div class="form-group">
<label for="eventtitle">Event Title:</label>
<input type="text" name="eventTitle" class="form-control" id="eventTitle" required="" value="Leave">
<!-- <input type="color" name="eventColor" class="form-control" id="eventColor" required="">-->
<input type="hidden" name="eventDate" class="form-control" id="eventDate">
</div>
<button type="submit" value="submit" name="submit" class="btn btn-default">Apply Leave</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Это код страницы просмотра. На этой странице, когда вы щелкаете по дате, когда она появляется, и я нажимаю кнопку Применить, данные сохраняются в database.but он не отображается на первой странице календаря при сохранении в базе данных.
Код моего контроллера
public function index()
{
if(isset($_POST["submit"]) == "submit" && isset($_POST["eventTitle"]) != "")
{
$da=array(
'title' => $this->input->post('eventTitle'),
'event_date'=> $this->input->post('eventDate'),
);
$sql = $this->db->insert('events',$da);
if ($sql) {
echo "New event added successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
$sql['row'] = $this->db->query("SELECT title, event_date as start, backgroundColor FROM events")->row_array();
if ($sql->num_rows > 0) {
// output data of each row
while($row = $sql->fetch_assoc()) {
$myArray[] = $row;
}
}
else
{
echo "0 results";
}
$this->load->view('Leave');
}
Отображается только значение «0» и некоторые ошибки