本文介绍了将jQuery fullcalendar集成到PHP网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将jQuery fullcalendar集成到我的PHP网站,但我不知道如何处理事件和如何使用MySQL的JSON数据。

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.

任何建议都会感激。

推荐答案

PHP可以输出f :

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>

  <script>
  $(document).ready(function(){
    $('#example').calendar();
  });
  </script>

</head>
<body>
  <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/themes/flora/flora.all.css" type="text/css" media="screen" title="Flora (Default)">
<script  src="http://dev.jquery.com/view/trunk/plugins/calendar/jquery-calendar.js"></script>
<input type="text" id="example" value="Click inside me to see a calendar" style="width:300px;"/>
</body>
</html>

以下是如何使用json_encode:

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();
         }
      });

   });

这里是PHP代码:

<?php

   $year = date('Y');
   $month = date('m');

   echo json_encode(array(

      array(
         'id' => 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/"
      )

   ));

?>

这篇关于将jQuery fullcalendar集成到PHP网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 19:09
查看更多