Hello,
I'm building a website where the user can login and add, update and remove events.
The events that are loaded at the start have to be the ones from that specific user.
Both the events and the user are loaded from my database.
I'm using this code on my index page:
function loadEvents() {
dp.events.load("backend_events.php");
}
loadEvents();
along with backend_events.php page:
<?php
$stmt = $db->prepare('SELECT * FROM events WHERE NOT ((end <= :start) OR (start >= :end)) AND userID = :userID');
$stmt->bindParam(':start', $_GET['start']);
$stmt->bindParam(':end', $_GET['end']);
$stlt->bindParam(':userID', $_GET['userID']); //Not sure if this is the correct way to do
$stmt->execute();
$result = $stmt->fetchAll();
class Event {}
$events = array();
foreach($result as $row) {
$e = new Event();
$e->id = $row['id'];
$e->text = $row['name'];
$e->start = $row['start'];
$e->end = $row['end'];
$events[] = $e;
}
header('Content-Type: application/json');
echo json_encode($events);
?>
I have no idea what to do because I can't add the extra value (userID) in dp.events.load.
Can anyone help me with this?
Thank you.