I do not know what I am doing when it comes to JSON. So this may be a stupid question and I may be trying to do it a weird way. Any help would be great.
I have this Jquery Calendar I am trying to put on my website. It allows for json_encode for dates. Here is the example they gave.
$year = date('Y');
$month = date('m');
echo json_encode(array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 222,
'title' => "Event2",
'start' => "$year-$month-20",
'end' => "$year-$month-22",
'url' => "http://yahoo.com/"
)
));
I want to use an existing mySQL database to populate the calendar. Here is what I have so far. It isn't working and I don't think I am being intelligent with this.
$dataSQL ="select *
FROM events
";
$dataResult = mysqli_query($dataBase, $dataSQL);
$encode = array();
$p=0;
while($allRow = mysqli_fetch_array($dataResult))
{
$new = array(
'id' => "$allRow['id']",
'title' => "$allRow['title']",
'start' => "$allRow['date']",
'url' => "$allRow['url']"
);
array_splice($encode, ($p), 0, $new);
$p++;
}
echo json_encode($encode);
Thanks in advance!