-
Notifications
You must be signed in to change notification settings - Fork 0
/
cars.php
108 lines (88 loc) · 2.79 KB
/
cars.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
<?php include 'db.php'; ?>
<?php
// We need to use sessions, so you should always start sessions using the below code.
// If the user is not logged in redirect to the login page...
if (!isset($_SESSION['loggedin'])) {
header('Location: index.php');
exit;
}
?>
<?php
// SELECT QUERY
$query = 'SELECT * FROM carmodels';
$results = mysqli_query($conn, $query);
if(isset($_GET['action']) && isset($_GET['id'])){
if($_GET['action'] == 'delete'){
$id = $_GET['id'];
$query = "DELETE FROM carmodels WHERE id = $id";
if(!mysqli_query($conn, $query)){
die(mysqli_error($conn));
} else {
header("Location: cars.php?success=Entry%20Removed");
}
}
}
if(isset($_GET['error'])){
$error = $_GET['error'];
}
if(isset($_GET['success'])){
$success = $_GET['success'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>List of instructors</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<header>
<nav class="site-nav">
<ul>
<li><a href="dashboard.php">Add Students</a></li>
<li><a href="report.php">Student List</a></li>
<li><a href="add-instructor.php">Add Instructor</a></li>
<li><a href="instructors.php">Instructor List</a></li>
<li><a href="add-car.php">Add Car</a></li>
<li><a href="cars.php">Car List</a></li>
<li><a href="price.php">Price List</a></li>
<li><a href="billing.php">Billing</a></li>
<li><a href="billing_report.php">Billing Report</a></li>
</ul>
</nav>
<nav class="site-nav-logout">
<ul>
<li><a href="logout.php">Logout</a></li>
</ul>
</nav>
<h2>List of available cars as per time.</h2>
</header>
<section class="instructors-table">
<table class="grocery-list">
<thead>
<tr>
<th class="col-item-name">Model Name</th>
<th class="col-quantity">Model Age</th>
<th class="col-price">Availability</th>
<th class="col-price">Timing</th>
<th class="col-price">Action</th>
</tr>
</thead>
<tbody>
<?php while($row = mysqli_fetch_assoc($results)) : ?>
<tr>
<td><?php echo $row['modelname']; ?> </td>
<td><?php echo $row['modelage']; ?></td>
<td><?php echo $row['slot']; ?></td>
<td><?php echo $row['time']; ?></td>
<td><a href="cars.php?action=delete&id=<?php echo $row['id']; ?>">Delete</a></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</section>
</div>
</body>
</html>