向日历添加事件不会保存到phpmyadmin数据库

moiiocjp  于 2021-06-17  发布在  Mysql
关注(0)|答案(0)|浏览(177)

我有一个日历,可以删除事件,但我不能将事件添加到日历,下面我附上了我使用的代码,如果有人可以帮助我发现哪里我做错了,我将不胜感激。
这段代码来自我的'event'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');
    },

这是我的“addevent”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);
}
?>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题