fullCalendar events post method to MySQL

后端 未结 3 1704
小蘑菇
小蘑菇 2020-12-16 05:55

I am attempting to create a MySQL backed events interface, using fullCalendar and MySQL. I have tried to manipulate the examples in the fullCalendar documentation and have s

相关标签:
3条回答
  • 2020-12-16 06:44

    print $query - there should be a ; at the end

    0 讨论(0)
  • 2020-12-16 06:47

    Once remove the column names in insert query and try, if you don't get then let's think about it. Do something like this

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

    Just print the post values before inserting, if it seems clear, then check your query.

    echo the query and exit, you may get something like this

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

    Run this query to find errors if any

    0 讨论(0)
  • 2020-12-16 06:50

    This is the conclusion I have come up with and I have no problem running this off my test and public server. I have taken the FullCalendar and this is the format I use.

    The database is real simple.

    id integer 11 chars primary key auto-increment,
    title varchar 50,
    start varchar 50,
    end varchar 50,
    url varchar 50.
    

    This is the index.php or index.html file.

    <!DOCTYPE html>
    <html>
    <head>
    <link href='css/fullcalendar.css' rel='stylesheet' />
    <link href='css/fullcalendar.print.css' rel='stylesheet' media='print' />
    <script src='js/jquery-1.9.1.min.js'></script>
    <script src='js/jquery-ui-1.10.2.custom.min.js'></script>
    <script src='js/fullcalendar.min.js'></script>
    <script>
        $(document).ready(function() {
            $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                editable: true,
                events: "json.php",
                eventDrop: function(event, delta) {
                    alert(event.title + ' was moved ' + delta + ' days\n' +
                        '(should probably update your database)');
                },
                loading: function(bool) {
                    if (bool) $('#loading').show();
                    else $('#loading').hide();
                }
            });
        });
    </script>
    <style>
        body {
            margin-top: 40px;
            text-align: center;
            font-size: 14px;
            font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
            } 
        #loading {
            position: absolute;
            top: 5px;
            right: 5px;
            }
        #calendar {
            width: 900px;
            margin: 0 auto;
            } 
    </style>
    </head>
    <body>
    <div id='loading' style='display:none'>loading...</div>
    <div id='calendar'></div>
    <p>json.php needs to be running in the same directory.</p>
    </body>
    </html>
    

    This is the json.php file.

    <?php
    mysql_pconnect("localhost", "root", "") or die("Could not connect");
    mysql_select_db("calendar") or die("Could not select database");
    
    
    $rs = mysql_query("SELECT * FROM events ORDER BY start ASC");
    $arr = array();
    
    while($obj = mysql_fetch_object($rs)) {
    $arr[] = $obj;
    }
    echo json_encode($arr);
    ?>
    
    0 讨论(0)
提交回复
热议问题