| ID | Nimi | Sihtkoht | Kuupäev | Lennujaam | Aviafirma | Hind (€) | Hotell | Ekskursioon |
|---|---|---|---|---|---|---|---|---|
| 1 | Egbert Michieli | Fontanges Airport | 2025-09-25 | Iokea Airport | Iberia | 2.99 | Baltic Horizon Hotel | jah |
| 2 | Garwood Hulcoop | In Salah Airport | 2025-09-25 | Hutchinson County Airport | KLM Royal Dutch Airlines | 79.99 | Nordic Star Hotel | jah |
| 3 | Darya Mitkin | Rivers Airport | 2025-09-25 | Guanacaste Airport | Air France | 1.99 | Nordic Star Hotel | jah |
| 4 | Diane Donnell | Albert J Ellis Airport | 2025-09-25 | Atizapan De Zaragoza Airport | American Airlines | 3.29 | Nordic Star Hotel | ei |
| 5 | Estella Gartenfeld | Yelizovo Airport | 2025-09-25 | São Filipe Airport | SAS Scandinavian | 2.99 | Seaside Palace Resort | jah |
| 6 | Mufinella Villa | Kandi Airport | 2025-09-25 | Lanzarote Airport | Avianca | 2.49 | Baltic Horizon Hotel | jah |
| 7 | Bernete Goldbourn | Barinas Airport | 2025-09-25 | Benin Airport | Air New Zealand | 2.99 | Baltic Horizon Hotel | jah |
| 8 | Jenni Rosle | Oshima Airport | 2025-09-25 | Kalpowar Airport | Southwest Airlines | 4.79 | Nordic Star Hotel | jah |
| 9 | Donetta Etchells | Naha Airport | 2025-09-25 | Woodward Field | Singapore Airlines | 2.49 | Nordic Star Hotel | jah |
| 10 | Clarissa Burghall | Kalpowar Airport | 2025-09-25 | Port Harcourt International Airport | SAS Scandinavian | 3.99 | Tallinn Grand Inn | jah |
| 11 | Kassie Scholes | Tarin Kowt Airport | 2025-09-25 | Termal Airport | South African Airways | 1.99 | Baltic Horizon Hotel | ei |
| 12 | Karon Sillitoe | Key West International Airport | 2025-09-25 | Ardmore Airport | Air New Zealand | 99.99 | Baltic Horizon Hotel | ei |
| 13 | Zaccaria Routledge | Boone County Airport | 2025-09-25 | Ndolo Airport | Air Canada | 4.99 | Tallinn Grand Inn | ei |
| 14 | Bret Gheorghe | Gode Airport | 2025-09-25 | New Ishigaki Airport | South African Airways | 59.99 | Nordic Star Hotel | ei |
| 15 | Ashlin Eckh | Gral. Bernardo O´Higgins Airport | 2025-09-25 | Juína Airport | British Airways | 5.49 | Baltic Horizon Hotel | ei |
| 16 | Elianora Gremain | Corcoran Airport | 2025-09-25 | Yorke Island Airport | Alitalia | 35.99 | Nordic Star Hotel | jah |
| 17 | Willyt Franklin | Garden Point Airport | 2025-09-25 | Namtu Airport | United Airlines | 49.95 | Baltic Horizon Hotel | jah |
| 18 | Gerrilee Jendricke | San Andros Airport | 2025-09-25 | Bob Sikes Airport | British Airways | 2.49 | Baltic Horizon Hotel | ei |
| 19 | Fern Jefferd | RAF Marham | 2025-09-25 | Ulgii Mongolei Airport | Thai Airways | 3.49 | Tallinn Grand Inn | jah |
| 20 | Isa Zaple | Port Stanley Airport | 2025-09-25 | Alexander Bay Airport | Lufthansa | 79.99 | Tallinn Grand Inn | jah |
| 21 | Sena State | Plymouth City Airport | 2025-09-25 | Malta International Airport | LATAM Airlines | 4.99 | Baltic Horizon Hotel | ei |
| 22 | Kirstin Sellstrom | Yap International Airport | 2025-09-25 | São Borja Airport | Air New Zealand | 6.99 | Tallinn Grand Inn | ei |
| 23 | Kata Pinney | Huesca/Pirineos Airport | 2025-09-25 | Owen Roberts International Airport | Thai Airways | 3.89 | Baltic Horizon Hotel | ei |
| 24 | Garey Derell | Keglsugl Airport | 2025-09-25 | Basongo Airport | Korean Air | 2.99 | Nordic Star Hotel | ei |
| 25 | Luis Lethby | Taean Airport | 2025-09-25 | Srednekolymsk Airport | Delta Air Lines | 3.59 | Seaside Palace Resort | ei |
| 26 | Felike Steane | Minden-Tahoe Airport | 2025-09-25 | Sundsvall-Härnösand Airport | Korean Air | 299.99 | Nordic Star Hotel | ei |
| 27 | Noemi Serman | Barra Airport | 2025-09-25 | Longdongbao Airport | British Airways | 59.99 | Tallinn Grand Inn | ei |
| 28 | Yance Swansborough | Sebba Airport | 2025-09-25 | Gebe Airport | SAS Scandinavian | 5.99 | Nordic Star Hotel | ei |
| 29 | Gerti Fairpo | Rivière-du-Loup Airport | 2025-09-25 | Sevilla Airport | Lufthansa | 4.99 | Tallinn Grand Inn | ei |
| 30 | Jed Morcombe | Kaolack Airport | 2025-09-25 | Cotulla-La Salle County Airport | American Airlines | 3.29 | Nordic Star Hotel | ei |
| 31 | d | d | 2025-10-17 | d | d | 2 | d | jah |
| 32 | w | w | 2025-10-09 | w | w | 2 | s | ei |
<!DOCTYPE html>
<html lang="et">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reisid PHP kaudu</title>
<link rel="stylesheet" href="style.css">
<style>
pre.code {
background-color: #222;
color: #0f0;
padding: 1em;
border-radius: 10px;
overflow-x: auto;
white-space: pre-wrap;
display: none;
}
form {
margin-bottom: 15px;
}
</style>
</head>
<body>
<h1>Reiside andmed PHP kaudu</h1>
<a href="index.html"><button>Tagasi avalehele</button></a>
<form method="get">
<label for="nimi">Otsi nime järgi:</label>
<input type="text" name="nimi" id="nimi" value="<?php echo htmlspecialchars($_GET['nimi'] ?? ''); ?>">
<label for="aviafirma">Otsi aviafirma järgi:</label>
<input type="text" name="aviafirma" id="aviafirma" value="<?php echo htmlspecialchars($_GET['aviafirma'] ?? ''); ?>">
<button type="submit">Otsi</button>
<a href="reis.php"><button type="button">Näita kõiki</button></a>
</form>
<?php
$jsonFile = 'reis.json';
if (!file_exists($jsonFile)) {
echo "<p class='error'>Viga: faili <strong>reis.json</strong> ei leitud!</p>";
exit;
}
$jsonData = file_get_contents($jsonFile);
$data = json_decode($jsonData, true);
if ($data === null || !isset($data['reisid'])) {
echo "<p class='error'>JSON fail on vigane või tühi.</p>";
exit;
}
$reisid = $data['reisid'];
// Фильтрация
$nimiFilter = strtolower($_GET['nimi'] ?? '');
$aviaFilter = strtolower($_GET['aviafirma'] ?? '');
if ($nimiFilter || $aviaFilter) {
$reisid = array_filter($reisid, function($r) use ($nimiFilter, $aviaFilter) {
return str_contains(strtolower($r['nimi']), $nimiFilter)
&& str_contains(strtolower($r['aviafirma']), $aviaFilter);
});
}
if (count($reisid) === 0) {
echo "<p>Ühtegi reisi ei leitud.</p>";
} else {
echo "<table>";
echo "<tr>
<th>ID</th>
<th>Nimi</th>
<th>Sihtkoht</th>
<th>Kuupäev</th>
<th>Lennujaam</th>
<th>Aviafirma</th>
<th>Hind (€)</th>
<th>Hotell</th>
<th>Ekskursioon</th>
</tr>";
foreach ($reisid as $reis) {
echo "<tr>";
echo "<td>" . htmlspecialchars($reis['id']) . "</td>";
echo "<td>" . htmlspecialchars($reis['nimi']) . "</td>";
echo "<td>" . htmlspecialchars($reis['sihtkoht']) . "</td>";
echo "<td>" . htmlspecialchars($reis['kuupaev']) . "</td>";
echo "<td>" . htmlspecialchars($reis['lennujaam']) . "</td>";
echo "<td>" . htmlspecialchars($reis['aviafirma']) . "</td>";
echo "<td>" . htmlspecialchars($reis['hind']) . "</td>";
echo "<td>" . htmlspecialchars($reis['hotell']) . "</td>";
echo "<td>" . htmlspecialchars($reis['ekskursioon']) . "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
<br>
<button onclick="toggleCode()">Näita PHP koodi</button>
<pre class="code" id="phpCode">
<?php
echo htmlspecialchars(file_get_contents(__FILE__));
?>
</pre>
<script>
function toggleCode() {
const pre = document.getElementById('phpCode');
pre.style.display = pre.style.display === 'block' ? 'none' : 'block';
}
</script>
</body>
</html>