I am trying to display events from a MySQL database in a full calendar.
Here is my code, json-events.php:
@mysql_connect($host,$user,$pass)
or die("Impossible de se connecter ! Vérifier le nom du serveur, le login ou le mot de passe !");
@mysql_select_db("$bdd")
or die ("Impossible de trouver la base de données !");
$req_lire ="SELECT idfiches,titrefiches,DATE_FORMAT(fiches.rvfiches, '%Y-%m-%d') as startdate FROM fiches";
$lire2 = mysql_query($req_lire) or die($req_lire."<br>\n".mysql_error());
$events = array();
while ($reponse = mysql_fetch_array($lire2))
{
$id = $reponse['idfiches'];
$title = $reponse['titrefiches'];
$start = $reponse['startdate'];
$events = array(
'id' => "$id",
'title' => "$title",
'start' => "$start"
);
}
echo json_encode($events);
Nothing is displayed and no error.
When I try my request in a sole file, it’s ok.
Could you help me?
First off, you’re replacing your $events array with whatever you got in the last iteration.
Try to update this:
into this:
That way, you’ll be appending each iteration’s data onto your $events array.