-
Notifications
You must be signed in to change notification settings - Fork 0
/
details uhhh the frontend.php
132 lines (120 loc) · 4.66 KB
/
details uhhh the frontend.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
require_once "admin/includes/logged.php";
require_once "admin/includes/conn.php";
require_once "admin/includes/helper.php";
if ($_SERVER["REQUEST_METHOD"] === "GET") {
if (isset($_GET['id'])) {
#if (!empty($_POST["idtea"])) {
try {
$sql = "SELECT * FROM `classes` WHERE id = ? AND pub =1;";
$stmt = $conn->prepare($sql);
$id = $_GET['id'];
$stmt->execute([$id]);
$class = $stmt->fetch();
#dd($class);
if ($class === false) { #lazem b3ad ma 3rft el class
header('Location: - index.php');
die();
}
// selected class
$sqltea = "SELECT * FROM `teachers` Where idtea = ?;";
$stmttea = $conn->prepare($sqltea);
$idtea = $class['idtea'];
$stmttea->execute([$idtea]);
$tea = $stmttea->fetch();
// related class with same teacher but not repeated
// $sqlCat = "SELECT * FROM `classes` Where idtea = ? AND pub = 1 AND id != ?;";
// $stmttea = $conn->prepare($sqltea);
// $teaid = $class['idtea'];
// $stmttea->execute([$idtea, $id]);
// $tea = $stmttea->fetchAll();
#dd($tea);
} catch (PDOException $e) {
$error = "Connection failed: " . $e->getMessage();
}
} else {
header('Location: - index.php');
} #die();
}
#}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Admin Dashboard</title>
<link rel="stylesheet" href="css/main.min.css" />
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<main>
<?php
require_once "admin/includes/NAVbar.php";
?>
<div class="container my-5">
<div class="bg-light p-5 rounded">
<form method="GET" action="" class="m-auto" style="max-width:600px" enctype="multipart/form-data">
<div class="card bg-light border-0">
<div class="row justify-content-center">
<div class="col-lg-4 col-md-6 col-10">
<img src="img/<?php echo $class['image'] ?>" alt="" class="card-img" width= "40%"/>
</div>
<div class="col-lg-8 col-md-6 col-12 card-body">
<div class="mb-4 text-center py-2">
<h2 class="fw-semibold bg-light card-header"><?php echo $class['name'] ?></h2>
</div>
<div class="mb-4">
<p class="card-text">
<span class="fw-bold" <?php echo $tea['idtea'] ?>>Teacher:</span> <?php echo $tea['fullname'] ?>
</p>
</div>
<div class="mb-4">
<p class="card-text">
<span class="fw-bold">Price:</span> <?php echo $class['price'] ?> $
</p>
</div>
<div class="mb-4">
<p class="card-text">
<span class="fw-bold">Published:</span> <?php echo ($class['pub'] === 1) ? "YES" : "NO"; ?>
</p>
</div>
<div class="row">
<div class="col-md-4" style="border-top: 3px solid #198754">
<p class="text-success fs-5 fw-bold lh-1 pt-2">Age:</p>
<p class="lh-1 fw-bold"> <?php echo $class['begAge'] ?> - <?php echo $class['endAge'] ?> Years</p>
</div>
<div class="col-md-4" style="border-top: 3px solid #fe5d37">
<p class="text-primary fs-5 fw-bold lh-1 pt-2">Time:</p>
<p class="lh-1 fw-bold"> <?php echo $class['begTime'] ?> - <?php echo $class['endTime'] ?> </p>
</div>
<div class="col-md-4" style="border-top: 3px solid #ffc107">
<p class="text-warning fs-5 fw-bold lh-1 pt-2">Capacity:</p>
<p class="lh-1 fw-bold"> <?php echo $class['capacity'] ?> kids</p>
</div>
</div>
<div class="text-md-end">
<a href="admin/classes.php"
class="btn mt-4 btn-primary text-white fs-5 fw-bold border-0 py-2 px-md-5"
>
Back to All classes
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<script src="js/bootstrap.bundle.min.js"></script>
<?php
if (isset($error)) {
?>
<div style="color: #ee0002; padding: 5px;">
<?php echo $error ?>
</div>
<?php
}
?>
</body>
</html>