= NOW() ORDER BY scheduled_at ASC LIMIT 50"; $stmt = $con->prepare($sql); $stmt->execute([$passengerId]); // $passengerId here is actually the user_id (driver's ID) } else { $sql = "SELECT * FROM scheduled_rides WHERE passenger_id = ?"; if ($scope === 'upcoming') { $sql .= " AND status = 'scheduled' AND scheduled_at >= NOW()"; } $sql .= " ORDER BY scheduled_at ASC LIMIT 50"; $stmt = $con->prepare($sql); $stmt->execute([$passengerId]); } jsonSuccess(['bookings' => $stmt->fetchAll(PDO::FETCH_ASSOC)], 'ok'); } catch (PDOException $e) { error_log('[scheduled/list] ' . $e->getMessage()); jsonError('DB Error', 500); }