Open giorgio83 opened 13 years ago
data: function(start, end, callback) { $.getJSON("event.php", { start: start.getTime(), end: end.getTime() }, function(result) { callback(result); }); }
include("db.php"); $srg = "SELECT * FROM calendar WHERE calendar.start >= ? AND calendar.end <= ?";
$snc = $dbh->prepare($srg);
$snc->execute(array(substr(date("c", substr($_GET["start"], 0, -3)), 0, 10), substr(date("c", substr($_GET["end"], 0, -3)), 0, 10)));
$first = true; $id = 1; $sData= "[";
foreach ($snc->fetchAll() as $str) { if ($first) $first = false; else $sData.= ','; $sData.= '{ "id":' . $id++ . ', "start": "' . $str["start"] . '", "end": "' . $str["end"] . '", "title":"' . $str["title"] . '", "body":"' . $str["body"] . '" }'; } $snc->closeCursor();
echo $sData. "]";
i hope will u help
HI webmaster666 how is the db.php coded, can u show?
Hi I am starting with jquery and I want to use this calendar but carrying my events from a database, for this demo I put the calendar on a page and then I edited the file by modifying the method getEventData demo.js where I have added a ajax function calling a php file that queries the database and bring the events, the data I see that brings me but from here and do not know how to assign my variable response below to return there instead of Sample loading events that bring mine loaded database. can someone help? this is my code:
function getEventData() { var year = new Date().getFullYear(); var month = new Date().getMonth(); var day = new Date().getDate(); $.ajax({ url: 'consulta.php', type: 'POST', success: function(respuesta){ alert(respuesta); } });
}