SalientAnimal Posted February 28, 2014 Share Posted February 28, 2014 Is there a limit on the number of "events" that a JSON array can hold? I have Calendar that displays events, and it works up until the point when I have 6 or more events in my calendar. The events are selected from a database table. Quote Link to comment https://forums.phpfreaks.com/topic/286610-json-array/ Share on other sites More sharing options...
gristoi Posted February 28, 2014 Share Posted February 28, 2014 (edited) no, there is no limit. I have json arrays with 100k + results. You are looking at the wrong thing. you need to see what your calendar is doing with the json results. and please be more clearer on excatly what is not working Edited February 28, 2014 by gristoi Quote Link to comment https://forums.phpfreaks.com/topic/286610-json-array/#findComment-1471053 Share on other sites More sharing options...
SalientAnimal Posted March 5, 2014 Author Share Posted March 5, 2014 Ok, first I just wanted to make sure that it wasn't a limitation thing. So here's what happens. When I have 5 Events or less the events display correctly in my calendar (array result set displays data). However as soon as I start adding more events to the calendar, my array result set is empty. I make no changes to the code at all, the only thing I am doing is adding data to my database. My table structure is as follows: id (auto increment int) title (varchar) agent_id (int) agent (varchar) start (datetime) end (datetime) url (varchar) allDay (varchar) Here this is my page that gathers the array from my table (The var_dump was just used to check my array set): <?php include_once '../includes/db_connect.php'; include_once '../includes/functions.php'; include_once '../includes/session_management.php'; $username = $_SESSION['username']; $email = $_SESSION['email']; $level = $_SESSION['level']; $user_id = $_SESSION['user_id']; // get the records from the database if ($result = $mysqli->query(" SELECT id , title , start , end , url , allDay FROM schedule WHERE agent_id = $user_id OR agent_id = 0 ORDER BY id ")); var_dump($_POST);exit; $arr = array(); while($row = mysqli_fetch_assoc($result)) { $arr[] = $row; } if($arr) { echo json_encode($arr); } else{ // here echo whatever you want to signify there were no results. } ?> This is the calendar itself: <!doctype html> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <html> <head> <link href='../events/fullcalendar/jquery-ui.min.css' rel='stylesheet' /> <link href='../events/fullcalendar/fullcalendar.css' rel='stylesheet' /> <link href='../events/fullcalendar/fullcalendar.print.css' rel='stylesheet' media='print' /> <script src='../events/lib/jquery.min.js'></script> <script src='../events/lib/jquery-ui.custom.min.js'></script> <script src='../events/fullcalendar/fullcalendar.min.js'></script> <script> $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); $('#calendar').fullCalendar({ theme: true, editable: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, events: '../events/events.unstripped.php', // Convert the allDay from string to boolean eventRender: function(event, element, view) { if (event.allDay === 'true') { event.allDay = true; } else { event.allDay = false; } }, selectable: true, selectHelper: true, select: function(start, end, allDay) { var title = prompt('Event Title:'); var url = prompt('Type Event url, if exits:'); if (title) { start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss"); end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss"); $.ajax({ url: '../events/add_events.php', data: 'title='+ title+'&start='+ start +'&end='+ end +'&url='+ url , type: "POST", success: function(json) { alert('Added Successfully'); location.reload(); } }); calendar.fullCalendar('renderEvent', { title: title, start: start, end: end, allDay: allDay }, true ); } calendar.fullCalendar('unselect'); }, editable: true, eventDrop: function(event, delta) { start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss"); end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss"); $.ajax({ url: '../calender/update_events.php', data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id , type: "POST", success: function(json) { alert("Updated Successfully"); } }); }, eventResize: function(event) { start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss"); end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss"); $.ajax({ url: '../events/update_events.php', data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id , type: "POST", success: function(json) { alert("Updated Successfully"); } }); } }); }); </script> <style> #calendar { width: 680px; margin: 0 auto; } </style> </head> <body> <div id='calendar'></div> </body> </html> If you could maybe give me some guidance where to do some additional trouble shooting. Quote Link to comment https://forums.phpfreaks.com/topic/286610-json-array/#findComment-1471486 Share on other sites More sharing options...
mac_gyver Posted March 5, 2014 Share Posted March 5, 2014 the php code you posted isn't using any $_POST data, so i don't know why you used var_dump($_POST); in it. you might want to use var_dump($arr); right before the point you have echo json_encode($arr); to see what data the query is retrieving. if your php code is retrieving the expected data, either there's something about that data or something in the calendar javascript that is causing the problem. what the author's site for the calendar javascript are you using? Quote Link to comment https://forums.phpfreaks.com/topic/286610-json-array/#findComment-1471513 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.