Integrating jQuery fullcalendar into PHP website

前端 未结 11 1015
夕颜
夕颜 2021-02-01 09:28

I would like to integrate the jQuery fullcalendar into my PHP website, but I don\'t know how to handle the event and how to use the JSON data from MySQL.

Any advice wou

11条回答
  •  自闭症患者
    2021-02-01 10:21

    Make sure that your PHP can output the following HTML code:

    
    
    
      
    
      
    
    
    
      
    
    
    
    
    

    Here's a sample how you can do it, by using json_encode:

    $(document).ready(function() { 
    
          $('#calendar').fullCalendar({ 
             draggable: true, 
             events: "json_events.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(); 
             } 
          }); 
    
       });
    

    And here's the PHP code:

     1, 
             'title' => "Event1", 
             'start' => "$year-$month-10", 
             'url' => "http://yahoo.com/" 
          ), 
    
          array( 
             'id' => 2, 
             'title' => "Event2", 
             'start' => "$year-$month-20", 
             'end' => "$year-$month-22", 
             'url' => "http://yahoo.com/" 
          ) 
    
       ));
    
    ?>
    

提交回复
热议问题