5

fullCalendar と MySQL を使用して、MySQL でサポートされているイベント インターフェイスを作成しようとしています。fullCalendar ドキュメントの例を操作してみましたが、データベースからイベント フィードを作成することに成功しました。

eventDropイベントID、タイトル、開始時間をデータベースに送信する呼び出しを作成しようとしています。前の質問のコードを使用して呼び出しを作成しましたeventDrop。カレンダー ページ全体の JavaScript は次のとおりです。

$(document).ready(function() {    
    /* initialize the external events
    -----------------------------------------------------------------*/

    $('#external-events div.external-event').each(function() {

        // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
        // it doesn't need to have a start or end
        var eventObject = {
            title: $.trim($(this).text()) // use the element's text as the event title
        };

        // store the Event Object in the DOM element so we can get to it later
        $(this).data('eventObject', eventObject);

        // make the event draggable using jQuery UI
        $(this).draggable({
            zIndex: 999,
            revert: true,      // will cause the event to go back to its
            revertDuration: 0  //  original position after the drag
        });                     
    });    

    /* initialize the calendar
    -----------------------------------------------------------------*/

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
        droppable: true, // this allows things to be dropped onto the calendar !!!
        drop: function(date, allDay) { // this function is called when something is dropped

            // retrieve the dropped element's stored Event Object
            var originalEventObject = $(this).data('eventObject');

            // we need to copy it, so that multiple events don't have a reference to the same object
            var copiedEventObject = $.extend({}, originalEventObject);

            // assign it the date that was reported
            copiedEventObject.start = date;
            copiedEventObject.allDay = allDay;

            // render the event on the calendar
            // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
            $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);                

            // if so, remove the element from the "Draggable Events" list
            $(this).remove();                     
        },

        // events from mysql database
        events: "/json-events.php",

        // submit to database
        eventDrop: function(calEvent, jsEvent, view) {
            var method = 'POST';
            var path = 'submit.php';
            var params = new Array();
            params['id'] = calEvent.id;
            params['start'] = calEvent.start;
             params['end'] = calEvent.end;
             params['title'] = calEvent.title;
            post_to_url( path, params, method);
  }
    });     
});

私が望んでいたPHPファイルは、POSTデータを受け取り、開始時間に15分を加えた時間に等しい終了時間でデータベースに挿入します(以下の回答後に編集):

<?php

mysql_connect("") or die(mysql_error());
mysql_select_db("") or die(mysql_error());

$id = $_POST["id"];
$title = $_POST["title"];
$start = $_POST["start"];
$end = date(Y-m-d T H:i:s , strtotime($start)+900);

$query = "INSERT INTO `events` VALUES (`$id`, `$title`, `$start`, `$end`, ``)";
mysql_query($query);
print $query;
?>

データベースがイベント データを受信して​​いません。

4

3 に答える 3

0

挿入クエリで列名を一度削除して試してみて、取得できない場合は考えてみましょう。このようなことをしてください

mysql_query(INSERT INTO `events` VALUES ('$id', '$title', '$start', '$end', ''));

挿入する前に投稿の値を出力するだけです。明らかな場合は、クエリを確認してください。

クエリをエコーし​​て終了すると、次のような結果が得られる場合があります

mysql_query(INSERT INTO `events` VALUES ('23', 'event title', 'start date', 'end date', ''));

エラーがある場合は、このクエリを実行してエラーを見つけます

于 2012-11-12T08:07:40.293 に答える
0

print $query;-最後に a があるはずです

于 2013-04-15T10:36:33.290 に答える