-
Notifications
You must be signed in to change notification settings - Fork 0
/
myGyms.php
86 lines (78 loc) · 3.04 KB
/
myGyms.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
<?php require_once __DIR__ . "/include/layout-start.php"; ?>
<?php
if( ! $helper->isUserLogin()){
$helper->Redirect(BASE_URL . 'login.php');
}
$user_id = $_SESSION['uid'];
if(isset($_GET['gym_id']) && !empty($_GET['gym_id'])){
$gym_id = $_GET['gym_id'];
$sqlGymChk = "SELECT a.* FROM tbl_gyms a WHERE a.id = $gym_id";
$resultGymChk = $conn -> query($sqlGymChk);
$rowGym = $resultGymChk -> fetch_assoc();
if($rowGym === false || empty($rowGym)){
$helper->SendErrorToast("Gym Doesn't Exist!!");
$helper->Redirect(BASE_URL . "myGyms.php");
}
$conn -> query("DELETE FROM tbl_gym_register WHERE gym_id = $gym_id AND user_id = $user_id");
$helper->SendSuccessToast("Gym Plan Canceled Successfully!!");
$helper->Redirect(BASE_URL . "myGyms.php");
}
$sql = "SELECT a.*, b.plan_id, c.name AS plan_name, c.price AS plan_price, b.date AS r_date FROM tbl_gyms a LEFT JOIN tbl_gym_register b ON a.id = b.gym_id LEFT JOIN tbl_gym_plans c ON c.id = b.plan_id WHERE b.user_id = $user_id";
$result = $conn -> query($sql);
$rows = $result -> fetch_all(MYSQLI_ASSOC);
?>
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">My Gyms</h1>
<p class="lead text-muted mx-5 px-5">You can browse your Registered Gyms.</p>
</div>
</section>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Gym Name</th>
<th scope="col">Gym Date</th>
<th scope="col">Plan Name</th>
<th scope="col">Plan Price</th>
<th scope="col">Register At</th>
<th scope="col">Details</th>
</tr>
</thead>
<tbody>
<?php
$sl = 0;
foreach ($rows as $key => $value) {
$sl++;
?>
<tr>
<th scope="row"><?=$sl?></th>
<td><?=$value['name']?></td>
<td><?=$value['date']?></td>
<td><?=$value['plan_name']?></td>
<td><?=$value['plan_price']?></td>
<td><?=$value['r_date']?></td>
<td>
<a href="<?=BASE_URL?>gymDetails.php?gym_id=<?=$value['id']?>">
View
</a>
<a class="ms-2" href="<?=BASE_URL?>myGyms.php?gym_id=<?=$value['id']?>">
Cancel
</a>
</td>
</tr>
<?php } ?>
<?php if($sl == 0) { ?>
<tr>
<td colspan="8">
<div class="text-center py-2">
No Gyms Registered
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php require_once __DIR__ . "/include/layout-end.php"; ?>