-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
104 lines (85 loc) · 2.62 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
require_once './app/config/connect.php';
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Главная страница</title>
<link rel="stylesheet" href="./app/assets/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 mt-4">
<?php
if (isset($_SESSION['message'])) {
?>
<h5 class="alert alert-success"><?php echo $_SESSION['message']; ?></h5>
<?php
} else {
unset($_SESSION['message']);
}
?>
<div class="card">
<div class="card-header">
<h3>CRUD - ( Создать , Прочитать , Обновить , Удалить )
<a href="./student-add.php" class="btn btn-primary float-end">Добавить студента</a>
</h3>
</div>
<div class="card-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Полное имя</th>
<th>Email</th>
<th>Телефон</th>
<th>Курс</th>
<th>Редактировать</th>
<th>Удалить</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT * FROM students";
$stmt = $connect->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
if ($result) {
foreach ($result as $value) {
?>
<tr>
<td><?php echo $value['id']; ?></td>
<td><?php echo $value['fullname']; ?></td>
<td><?php echo $value['email']; ?></td>
<td><?php echo $value['phone']; ?></td>
<td><?php echo $value['course']; ?></td>
<td><a href="./update.php?id=<?php echo $value['id']; ?>" class="btn btn-success">Редактировать</a></td>
<td>
<form action="./app/vendor/delete.php" method="POST">
<button type="submit" name="deleteStudentBtn" value="<?php echo $value['id']; ?>" class="btn btn-danger">Удалить</button>
</form>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="5">Записи о студентах не найдены</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>