สอบถามเรื่องทำปฏิทินกิจกรรม
สอบถามเรื่องทำปฏิทินกิจกรรม พอรันแล้วค่าในฐานข้อมูลมันไม่ออกเลยค่ะ ออกแต่ปฎิทิน
ไม่ทราบว่าเราจะ error หรือเช็คว่าค่ามันส่งรึป่าวทำยังไงอะค่ะ ขอบคุณค่ะ
โค๊ดที่ใช้รัน
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prac full calendar</title>
<link rel='stylesheet' type='text/css' href='fullcalendar/redmond/theme.css' />
<link rel='stylesheet' type='text/css' href='fullcalendar/fullcalendar.css' />
<script type='text/javascript' src='fullcalendar/jquery/jquery.js'></script>
<script type='text/javascript' src='fullcalendar/jquery/jquery-ui-custom.js'></script>
<script type="text/javascript" src="fullcalendar/fullcalendar.min.js"></script>
<script type="text/javascript">
$(function(){
$('#calendar').fullCalendar({
header: {
left: 'month,agendaWeek,agendaDay',
center: 'title',
right: 'prev,next today'
},
editable: true,
theme:true,
events:"getCalendar.php?gData=1",
loading:function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
// put your options and callbacks here
});
});
</script>
<style type="text/css">
body{
padding:0px;
margin:0px;
font-size:12px;
font-family:Tahoma, Geneva, sans-serif;
}
#calendar{
width:750px;
margin:auto;
}
</style>
</head>
<body>
<br />
<br />
<div id='calendar'></div>
</body>
</html>
หน้าที่เรียกใช้งาน
<?php
header("Content-type:text/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
$con_db=mysql_connect("127.0.0.1","root","test") or die("Cannot connect db server");
$select_db=mysql_select_db("test");
if($_GET['gData']){
$event_array=array();
$i_event=0;
$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";
$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'];
$event_array[$i_event]['allDay']=($rs['event_allDay']=="true")?true:false;
$i_event++;
}
echo json_encode($event_array);
exit;
}
?>
ไม่ทราบว่าเราจะ error หรือเช็คว่าค่ามันส่งรึป่าวทำยังไงอะค่ะ ขอบคุณค่ะ
โค๊ดที่ใช้รัน
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prac full calendar</title>
<link rel='stylesheet' type='text/css' href='fullcalendar/redmond/theme.css' />
<link rel='stylesheet' type='text/css' href='fullcalendar/fullcalendar.css' />
<script type='text/javascript' src='fullcalendar/jquery/jquery.js'></script>
<script type='text/javascript' src='fullcalendar/jquery/jquery-ui-custom.js'></script>
<script type="text/javascript" src="fullcalendar/fullcalendar.min.js"></script>
<script type="text/javascript">
$(function(){
$('#calendar').fullCalendar({
header: {
left: 'month,agendaWeek,agendaDay',
center: 'title',
right: 'prev,next today'
},
editable: true,
theme:true,
events:"getCalendar.php?gData=1",
loading:function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
// put your options and callbacks here
});
});
</script>
<style type="text/css">
body{
padding:0px;
margin:0px;
font-size:12px;
font-family:Tahoma, Geneva, sans-serif;
}
#calendar{
width:750px;
margin:auto;
}
</style>
</head>
<body>
<br />
<br />
<div id='calendar'></div>
</body>
</html>
หน้าที่เรียกใช้งาน
<?php
header("Content-type:text/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
$con_db=mysql_connect("127.0.0.1","root","test") or die("Cannot connect db server");
$select_db=mysql_select_db("test");
if($_GET['gData']){
$event_array=array();
$i_event=0;
$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";
$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'];
$event_array[$i_event]['allDay']=($rs['event_allDay']=="true")?true:false;
$i_event++;
}
echo json_encode($event_array);
exit;
}
?>
แล้วการใช้ json นี่ต้องโหลดอะไรมาลงเหมือน jquery อีกหรือไม่ครับ