fullcalendar-如何在db中为每个用户加载计划

ds97pgxw  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(184)

我正在使用fullcalendar。当我添加时间表时,我将用户的电话号码存储在数据库中。在获取时,我想获取用php中的用户电话号码分隔的时间表。我该怎么办?
测试.js

var calendar = $('#calendar').fullCalendar({
    height:650,
    locale:'ko',
    editable: true,
    header:{
         left:'prev,next today',
         center:'title',
         right:'month,agendaWeek,agendaDay,listDay'
     },
   events: function(start,end,callback){
                var pno="2154421215";
                $.ajax({
                       url: 'fetch-event.php',
                       data: {pno:pno}, 
                       type: "POST",   
                       success: function (obj) {
                                var events = [];
                                $.each(obj, function(index, value) {
                                      events.push({
                                           id: value['id'],
                                           start: value['start'],                                                                
                                           title: value['title'],                                                                                                    
                                           end: value['end']
                                      });                                                                                       
                                });

                       callback(events);
                 }

    },
   displayEventTime: true,
   eventRender: function (event, element, view) {
        if (event.allDay === 'true') {
            event.allDay = true;
        } else {
            event.allDay = false;
        }
    },

   eventLimit: true,
   selectable: true,
   selectHelper: true,
   select: function (start, end, allDay) {
        var title = prompt('input title:');
        var pno="2154421215";
        if (title) {
            var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
            var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");

            $.ajax({
                url: 'add-event.php',
                data: 'title=' + title + '&start=' + start + '&end=' + end + '&pno=' + pno ,
                type: "POST",
                success: function (data) {
                   alert("success");
                }
            });
            calendar.fullCalendar('renderEvent',
                    {
                        title: title,
                        start: start,
                        end: end,
                        allDay: allDay
                    },
            true
                    );
        }
        calendar.fullCalendar('unselect');
    },

    editable: false,
    eventClick: function (event) {
        var deleteMsg = confirm("delete?");
        if (deleteMsg) {
            $.ajax({
                type: "POST",
                url: "delete-event.php",
                data: "&id=" + event.id,
                success: function (response) {
                    if(parseInt(response) > 0) {
                        $('#calendar').fullCalendar('removeEvents', event.id);
                        alert("success");
                    }
                }
            });
        }
    }

});

fetch-event.php文件

<?php  
$`pno = `$_POST`['pno'];
$json = array();
$sqlQuery = "SELECT * FROM calendar WHERE pno='".$pno."' ORDER BY id";
$result = mysqli_query($conn, $sqlQuery);
$eventArray = array();
while ($row = mysqli_fetch_assoc($result)) {
    array_push($eventArray, $row);
}
mysqli_free_result($result);

mysqli_close($conn);
echo json_encode($eventArray);
?>

暂无答案!

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

相关问题