Fullcalendar not showing up events - PHP mysql -
i using full calendar in php application. issue events don't show in calendar.
calendar.php -
<?php $host = "localhost"; $user = "myusername"; $pw = "mypass"; $database = "mydb"; $db = mysql_connect($host,$user,$pw) or die("cannot connect mysql."); mysql_select_db($database,$db) or die("cannot connect database."); $year = date('y'); $month = date('m'); $command = "select * `calendar_urls` "; $result = mysql_query($command, $db); while ($row = mysql_fetch_assoc($result)) { $url = $row['calendar_array']; $urls[] = $url; } ?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html> <head> <link rel='stylesheet' type='text/css' href='fullcalendar/fullcalendar.css' /> <link rel='stylesheet' type='text/css' href='fullcalendar/fullcalendar.print.css' media='print' /> <script type='text/javascript' src='jquery/jquery-1.7.1.min.js'></script> <script type='text/javascript' src='jquery/jquery-ui-1.8.17.custom.min.js'></script> <script type='text/javascript' src='fullcalendar/fullcalendar.min.js'></script> <script type='text/javascript' src='fullcalendar/gcal.js'></script> <script> $(document).ready(function() { $('#calendar').fullcalendar({ header: { left: 'prev,next', center: 'title', right: 'month,basicweek,basicday' }, editable: true, //events: 'https://www.google.com/calendar/feeds/kelchuk68%40gmail.com/public/basic/', eventsources: [ //get_string(), /*'https://www.google.com/calendar/feeds/kelchuk68%40gmail.com/public/basic', 'events.php',*/ <?php echo implode(",", $urls); ?> ] }); }); </script> <style type='text/css'> body { margin-top: 40px; text-align: center; font-size: 14px; font-family: "lucida grande",helvetica,arial,verdana,sans-serif; } #calendar { width: 900px; margin: 0 auto; } </style> </head> <body> <div style="display:block; width:900px; margin: 0 auto; "> <div style="float:right; margin-bottom:10px;"> <form action="<?php echo $_server[php_self]; ?>" method="post"> <input type="submit" name="add_event" value="add event"/> </form> <p style="display:none">add event | edit event | delete event</p></div> </div> <div style="clear:both;"></div> <?php if($_post['add_event']){ $year = date("y"); $year2= $year + 1; $mymonth = date("m"); $day = date("d");?> <div style="background-color:grey; width:900px; margin:0 auto;padding-top:20px;padding-bottom:10px; border-radius:15px;"> <form action="<?php echo $_server[php_self]; ?>" method="post"> <div style="float:left;margin-left:10px;">title: <input style="margin:0 auto; text-align:left;" type="text" name="event_title" value=""/> <select name ="year"> <?php echo '<option selected="selected">'.$year.'</option>'; echo '<option>'.$year2.'</option>'; echo '</select>'; ?> <select name ="month"> <?php $month = array($month); echo '<option selected="selected">'.$mymonth.'</option>'; $months = array('01','02','03','04','05','06','07','08','09','10','11','12'); $months = array_diff($months,$month); foreach($months $month_opt){ echo '<option>'.$month_opt.'</option>'; } echo '</select>'; ?> <select name="day"> <?php echo '<option selected="selected">'.$day.'</option>'; for($i=1; $i<32; $i++) { echo '<option>'.$i.'</option>'; } echo '</select>'; ?>   hour: <select name="hour"> <?php $hours = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'); foreach($hours $hour){ echo '<option>'.$hour.'</option>'; } echo '</select>'; ?>   minutes: <select name="minutes"> <?php $minutes = array('00','15','30','45'); foreach($minutes $minute){ echo '<option>'.$minute.'</option>'; } echo '</select>'; echo'</div>'; ?><br/><br/> <div style="float:left;margin-left:10px;margin-bottom:5px;">notes:</div> <textarea name="notes" style="width:880px; margin:0 auto;"></textarea><br/> <?php echo '<input style="margin-top:10px;" type="submit" name="adding" value="add event"/></form></div><br/><br/>'; } if($_post['adding']) { $year = $_post['year']; $month = $_post['month']; $day= $_post['day']; $hour= $_post['hour']; $minutes= $_post['minutes']; $fulldate = $year."-".$month."-".$day." ".$hour.":".$minutes; $command = "insert calendar values('','0', '{$_post['event_title']}', '{$_post['notes']}', '$fulldate','') "; $result = mysql_query($command, $db); if($result) { echo "successful insert!"; } } ?> <div style="clear:both;"></div> <div id='calendar'></div> </body> </html>
the calendar shows properly. lets user add events events not displayed.
2 tables used calendar contain following -
this events.php-
<?php session_start(); date_default_timezone_set('asia/calcutta'); include ("connect.inc"); $db = public_db_connect(); $year = date('y'); $month = date('m'); $command = "select * `calendar`"; $result = mysql_query($command, $db); while ($row = mysql_fetch_assoc($result)) { //echo "hi"; //$start = date("d, j m y g:i:s t", strtotime($row['start'])); //$end = date("d, j m y g:i:s t", strtotime($row['end_time'])); $start = date("y-m-d", strtotime($row['start'])); //$start = "$year-$month-20"; $myid = $row['id']; $eventsarray['id'] = (int)trim($myid); $eventsarray['title'] = $row['title']; $title = date("g:ia", strtotime($row['start']))." ".$row['title']; //$title = $row['title']; //echo $title; $eventsarray['title'] = $title; $eventsarray['start'] = $start; /*$eventsarray['end'] = $start;*/ $eventsarray['url'] = "edit_calendar.php?calendarid=".$row['id']; // $eventsarray['end'] = $end; // $eventsarray['allday'] = false; $events[] = $eventsarray; } echo json_encode($events);
connect.inc -
<?php function public_db_connect() { $host = "localhost"; $user = "myuser"; $pw = "mypass"; $database = "mydb"; $db = mysql_connect($host,$user,$pw) or die("cannot connect mysql."); mysql_select_db($database,$db) or die("cannot connect database."); return $db; } ?>
i don't know calendar url , why has google link came site downloaded calendar.
thanks.
Comments
Post a Comment