prepare("SELECT * FROM stations WHERE code = ?");
$sq->execute([$code]);
$st = $sq->fetch(PDO::FETCH_ASSOC);
if (!$st) {
http_response_code(404);
$page_title = 'Station ' . $code . ' not found';
$meta_robots = 'noindex';
require APP_DIR . '/header.php';
echo '
Station ' . e($code) . ' not found
Search journeys.
';
require APP_DIR . '/footer.php';
exit;
}
$tq = $pdo->prepare(
"SELECT t.train_no, t.train_name, t.train_type, t.source_code, t.dest_code, t.run_days,
ts.arrival, ts.departure
FROM train_stops ts
JOIN trains t ON t.train_no = ts.train_no
WHERE ts.station_code = ? AND t.run_days IS NOT NULL
ORDER BY COALESCE(ts.departure, ts.arrival)"
);
$tq->execute([$code]);
$rows = $tq->fetchAll(PDO::FETCH_ASSOC);
$name = $st['name'] ?: $code;
$cnt = count($rows);
$page_title = 'Trains at ' . $name . ' (' . $code . ') — Time Table';
$meta_description = $cnt . ' trains stop at ' . $name . ' (' . $code . '). See arrival and departure times and plan direct or connecting journeys. Indicative times — verify before travel.';
$canonical = rr_abs(rr_station_url($code));
if ($cnt === 0) $meta_robots = 'noindex';
$crumb = ['@context' => 'https://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => [
['@type' => 'ListItem', 'position' => 1, 'name' => 'Home', 'item' => rr_abs('/')],
['@type' => 'ListItem', 'position' => 2, 'name' => $name . ' (' . $code . ')', 'item' => $canonical],
]];
$ld = ['@context' => 'https://schema.org', '@type' => 'TrainStation', 'name' => $name, 'identifier' => $code];
if (isset($st['lat'], $st['lng']) && $st['lat'] !== null && $st['lat'] !== '' && $st['lng'] !== null && $st['lng'] !== '') {
$ld['geo'] = ['@type' => 'GeoCoordinates', 'latitude' => (float) $st['lat'], 'longitude' => (float) $st['lng']];
}
$head_extra = ''
. '';
require APP_DIR . '/header.php';
?>
= e($name) ?> (= e($code) ?>)
= e($cnt) ?> trains with a confirmed timetable stop here.
Trains calling at = e($name) ?>
No confirmed trains yet for this station.
| Train |
Name |
Arr |
Dep |
Runs |
| = e($r['train_no']) ?> |
= e($r['train_name'] ?: '') ?> |
= e(rr_time($r['arrival'])) ?> |
= e(rr_time($r['departure'])) ?> |
= e(rr_run_days_text($r['run_days'])) ?> |
Indicative times based on a reference timetable. Confirm on official sources before travel.