php - 将 jQuery fullcalendar 集成到 PHP 网站中

标签 php jquery calendar fullcalendar

我想将 jQuery 全日历集成到我的 PHP 网站中,但我不知道如何处理该事件以及如何使用 MySQL 中的 JSON 数据。

如有任何建议,我们将不胜感激。

最佳答案

确保您的 PHP 可以输出 f ollowing 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>

这是 a sample如何使用 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/" 
      ) 

   ));

?>

关于php - 将 jQuery fullcalendar 集成到 PHP 网站中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1666146/

相关文章:

php - 使用 laravel 进行 REST api 身份验证

javascript - 附加后未删除 jQuery 字段

javascript - 将包装器置于水平网站的中心

javascript - JQuery UI Slider - 多个 slider 的组合最大值也有各自的最大值

java - 将字符串数组添加到日历数组中

php - 如何使用 Zend Framework 2 设置 Redis 缓存?

php - 如何将 URL 重定向到父 iframe

swift - 快速获取日期名称和日期在日期范围内重复的次数

java - 将字符串转换为星期几(不是确切日期)

php - 为什么我的 CSS 没有按应有的方式更改?