PHP_DS_Project/www2databaze/zaci.php

57 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?php
2024-09-24 15:48:46 +00:00
global $connection;
2024-09-25 15:40:03 +00:00
require "assets/database.php";
2024-09-23 15:54:58 +00:00
$sql = "SELECT * FROM student";
2024-09-24 15:48:46 +00:00
2024-09-30 15:49:39 +00:00
$connection = connectionDB();
2024-09-23 15:54:58 +00:00
$result = mysqli_query($connection, $sql);
2024-09-24 15:48:46 +00:00
if ($result === false) {
echo mysgli_error($connection);
} else {
$students = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
2024-09-23 15:54:58 +00:00
//var_dump($students);
?>
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
2024-09-25 15:40:03 +00:00
<?php require "assets/header.php" ?>
<main>
<section class="main-heading"><h1>Seznam žáků školy</h1></section>
<section class="students-list">
<?php
if(empty($students)):
?>
<p>Žádní žáci nebyli nalezeni</p>
<?php else: ?>
<ul>
<?php foreach ($students as $one_student): ?>
<li><?= htmlspecialchars($one_student["first_name"]). " " .htmlspecialchars($one_student["second_name"]) ?></li>
2024-09-25 15:40:03 +00:00
<a href="jeden-zak.php?id=<?= $one_student['id'] ?>">Více informací</a>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<a href="index.php">Zpět na hlavní stranu</a>
</section>
</main>
<?php require "assets/footer.php" ?>
2024-09-23 15:54:58 +00:00
</body>
</html>