Jump to content

JSON Array


SalientAnimal

Recommended Posts

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 by gristoi
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.