我有一个日历,可以删除事件,但是我不能向日历中添加事件,下面附有我正在使用的代码,如果有人可以帮助我发现我要去哪里,我将不胜感激。
此代码来自我有日历的“事件” php文件
$(document).ready(function ()
{
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,week,Day'
},
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true,
events: "all_events.php",
displayEventTime: false,
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Event Detail:', 'Event Time:','No of People');
if (title) {
var start = $.formatDate(start, "Y-MM-DD");
var end = $.formatDate(end, "Y-MM-DD");
var time = $.formatTime(time, "HH:mm:ss");
$.ajax({
url: 'add_event.php',
data: 'title=' + title + '&start=' + start + '&end=' + end,
type: "POST",
success: function (data) {
displayMessage("Added Successfully");
}
});
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true
);
}
calendar.fullCalendar('unselect');
},
这是我的“添加事件” php文件,我在其中编写了将数据写入数据库的代码
<?php
require_once "config.php";
$title = $_POST['title'];
$start = $_POST['start'];
$end = $_POST['end'];
$sqlInsert = "INSERT INTO events (title,start,end) VALUES ('". $title ."','". $start ."','". $end ."')";
$result = mysqli_query($conn, $sqlInsert);
if (! $result) {
$result = mysqli_error($conn);
}
?>