-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_room.php
54 lines (45 loc) · 1.79 KB
/
update_room.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
<?php
include('dbcon.php');
$row = array();
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT * FROM room WHERE roomID = '$id'";
$result = mysqli_query($connection, $query);
if (!$result) {
die("Query Failed: " . mysqli_error($connection));
} else {
$row = mysqli_fetch_assoc($result);
}
}
if (isset($_POST['update_room'])) {
if (isset($_GET['id'])) {
$idnew = $_GET['id'];
}
$roomnumber = $_POST['roomnumber'];
$location = $_POST['location'];
$availability = $_POST['availability'];
$query = "UPDATE room SET roomNo = '$roomnumber', Location = '$location', Availability = '$availability' WHERE roomID = '$idnew'";
$result = mysqli_query($connection, $query);
if (!$result) {
die("Query failed: " . mysqli_error($connection));
} else {
header('location:index.php?update_msg=You have successfully updated the data.');
}
}
?>
<form action="delete_room.php?id=<?php echo $id; ?>" method="post">
<div class="form-group">
<label for="roomnumber">Room Number</label>
<input type="text" name="roomnumber" class="form-control" value="<?php echo isset($row['roomNo']) ? $row['roomNo'] : ''; ?>">
</div>
<div class="form-group">
<label for="location">Location</label>
<input type="text" name="location" class="form-control" value="<?php echo isset($row['Location']) ? $row['Location'] : ''; ?>">
</div>
<div class="form-group">
<label for="availability">Availability</label>
<input type="text" name="availability" class="form-control" value="<?php echo isset($row['Availability']) ? $row['Availability'] : ''; ?>">
</div>
<input type="submit" class="btn btn-success" name="update_room" value="UPDATE">
</form>
<?php include('footer.php'); ?>