ช่วยประยุก Calendar ตัวนี้ ให้มันดึงข้อมูลจาก ฐานข้อมูลมาทำงานทีครับ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา ช่วยประยุก Calendar ตัวนี้ ให้มันดึงข้อมูลจาก ฐานข้อมูลมาทำงานทีครับ

ช่วยประยุก Calendar ตัวนี้ ให้มันดึงข้อมูลจาก ฐานข้อมูลมาทำงานทีครับ

 ช่วยประยุก Calendar ตัวนี้ ให้มันดึงข้อมูลจาก ฐานข้อมูลมาทำงานทีครับ
แบบ ว่าผมลองดาวน์โหลดมาเล่นแล้ว มันมีการทำงานกับ PHP ด้วย แต่เอามาประยุกต์ ใช้งานไม่เป็น จึงมารบกวน คุร นิก ช่วยที ครับ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
header("Content-type:text/html; charset=windows-874");    
 
    $year = date('Y');
    $month = date('m');
 
    echo json_encode(array(
     
        array(
            'id' => 111,
            'title' => "Test System ทดสอบระบบ",
            'start' => "$year-$month-10",
            'url' => "http://yahoo.com/"
        ),
         
        array(
            'id' => 222,
            'title' => "Event2",
            'start' => "$year-$month-20",
            'end' => "$year-$month-22",
            'url' => "http://yahoo.com/"
        ),
         
        array(
            'id' => 333,
            'title' => "Event3 ทดสอบระบบ",
            'start' => "$year-$month-05",
            'end' => "$year-$month-24",
            'url' => "http://srenon.com/"
        )
                 
    ));
?>

 



นายศราวุฒิ 31-07-2010 22:37:41

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1

 ลืม ฝากลิ้ง อิอิ http://arshaw.com/fullcalendar/



นายศราวุฒิ 31-07-2010 22:38
 ความคิดเห็นที่ 2

เหมือนจะเคยถามแล้วครั้งหนึ่งหรือป่าว จำไม่ได้ แต่เคยเล่นตัวนี้อยู่ น่าจะมีข้อมูล เก่า



Ninenik 31-07-2010
 ความคิดเห็นที่ 3

ตาราง ฐานข้อมูลทดสอบ
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--
-- Table structure for table `tbl_event`
--
 
CREATE TABLE `tbl_event` (
  `event_id` int(11) NOT NULL auto_increment,
  `event_title` varchar(255) NOT NULL,
  `event_start` datetime NOT NULL,
  `event_end` datetime NOT NULL,
  `event_url` varchar(255) NOT NULL,
  PRIMARY KEY  (`event_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
 
--
-- Dumping data for table `tbl_event`
--
 
INSERT INTO `tbl_event` VALUES (1, 'event1', '2010-06-02 20:35:38', '2010-06-08 20:35:52', 'https://www.ninenik.com');
INSERT INTO `tbl_event` VALUES (2, 'event2', '2010-07-12 20:36:16', '2010-07-14 20:36:16', 'https://www.ninenik.com');
INSERT INTO `tbl_event` VALUES (3, 'event3', '2010-06-23 20:37:06', '2010-06-24 20:37:06', 'http://www.google.com');


 ตัวอย่างไฟล์ prac_fullcalendar.php
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
if($_GET['gData']){
/*  $year = date('Y');
    $month = date('m');
 
    echo json_encode(array(
     
        array(
            'id' => 111,
            'title' => "Event1",
            'start' => "$year-$month-10",
            'url' => "http://yahoo.com/"
        ),
         
        array(
            'id' => 222,
            'title' => "Event2",
            'start' => "$year-$month-20",
            'end' => "$year-$month-22",
            'url' => "http://yahoo.com/"
        )
     
    ));*/
     
/*  $test_arr=array(
     
        array(
            'id' => 111,
            'title' => "Event1",
            'start' => "$year-$month-10",
            'url' => "http://yahoo.com/"
        ),
         
        array(
            'id' => 222,
            'title' => "Event2",
            'start' => "$year-$month-20",
            'end' => "$year-$month-22",
            'url' => "http://yahoo.com/"
        )
     
    );
    echo "<pre>";
    print_r($test_arr);
    echo "</pre>";*/
    $event_array=array();
    $i_event=0;
    $con_db=mysql_connect("localhost","root","test") or die("Cannot connect db server");
    $select_db=mysql_select_db("test");
    $q="SELECT * FROM tbl_event ORDER by event_id ";
    $qr=mysql_query($q);
    while($rs=mysql_fetch_array($qr)){
        $event_array[$i_event]['id']=$rs['event_id'];
        $event_array[$i_event]['title']=$rs['event_title'];
        $event_array[$i_event]['start']=$rs['event_start'];
        $event_array[$i_event]['end']=$rs['event_end'];
        $event_array[$i_event]['url']=$rs['event_url'];
        $i_event++;
    }
    echo json_encode($event_array);
/*  echo "<pre>";
    print_r($event_array);
    echo "</pre>";   
    echo mysql_num_rows($qr);   */
    exit;  
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prac full calendar</title>
<style type="text/css">
body{
    padding:0px;
    margin:0px;
    font-size:12px;
    font-family:Tahoma, Geneva, sans-serif;
}
#calendar{
    width:900px;   
    margin:auto;
}
</style>
</head>
 
<body>
<br />
<br />
 
<div id='calendar'></div>
<link rel='stylesheet' type='text/css' href='redmond/theme.css' />
<link rel='stylesheet' type='text/css' href='fullcalendar.css' />
<script type='text/javascript' src='jquery/jquery.js'></script>
<script type='text/javascript' src='fullcalendar.js'></script>
<script type="text/javascript">
$(function(){
    $('#calendar').fullCalendar({
        header: {
                left: 'month,basicWeek,basicDay',
                center: 'title',
                right: 'prev,next today'
        },
        editable: true,
        theme:true,
        events: "prac_fullcalendar.php?gData=1",
        loading: function(bool) {
                if (bool) $('#loading').show();
                else $('#loading').hide();
        }
        // put your options and callbacks here
    });
     
});
</script>
 
 
</body>
</html>

 



Ninenik 31-07-2010
 ความคิดเห็นที่ 4

 ขอบคุณครับ



นายศราวุฒิ 01-08-2010 10:26
 ความคิดเห็นที่ 5

คำสั่ง sql มัน select ดึงข้อมูลมาทั้งหมดครับ ถ้าหากข้อมูลใน DB มีเยอะๆ อาจจะทำให้มันรันช้าขึ้นหรือเปล่าครับ ?

พอจะเป็นไปได้ไหมครับ คืออยากให้เวลาเราเลือกปฏิทินไปเดือนไหน ก็ให้มันดึงข้อมูลใน db เฉพาะเดือนนั้นออกมาครับ

รบกวนด้วยครับ ขอบคุณครับ



สุทธิพงษ์ 04-08-2010 15:03
 ความคิดเห็นที่ 6

จากความคิดเห็นที่ 3  ให้เปลี่ยนบรรทัดที่ 50
 

1
$q="SELECT * FROM tbl_event ORDER by event_id ";

เป็น
 

1
2
$q="SELECT * FROM tbl_event WHERE date(event_start)>='".date("Y-m-d",$_GET['start'])."'  ";
$q.=" AND date(event_end)<='".date("Y-m-d",$_GET['end'])."' ORDER by event_id";

 



ninenik 04-08-2010
 ความคิดเห็นที่ 7

ขอบคุณครับ



สุทธิพงษ์ 05-08-2010 12:10
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ