-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfloor.php
156 lines (141 loc) · 4.83 KB
/
floor.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
$conn=mysqli_connect("localhost","root","");
$db=mysqli_select_db($conn,"hotel_db");
if(isset($_POST['submit_e']))
{
$floor_no=$_POST['floor_no_e'];
$floor_name=$_POST['floor_name_e'];
$floor_status=$_POST['status_e'];
$floor_id=$_POST['floor_id_e'];
$query="update floor_info set floor_no=$floor_no,floor_name='$floor_name',floor_status=$floor_status where floor_id=$floor_id";
echo $query;
$result=mysqli_query($conn,$query);
if($result)
{
?>
<script>location.replace('floor.php');</script>
<?php
}
}
if(isset($_GET['uid']))
{
$floor_id=$_GET['uid'];
$query="delete from floor_info where floor_id=$floor_id";
$result=mysqli_query($conn,$query);
if($result)
{
?>
<script>alert('Deleted');location.replace('floor.php?')</script>
<?php
}
}
if(isset($_POST['submit']))
{
$floor_name=$_POST['floor_name'];
$floor_no=$_POST['floor_no'];
$floor_status=$_POST['status'];
$query="insert into floor_info(floor_no,floor_status,floor_name)values('$floor_no','$floor_status','$floor_name')";
$result=mysqli_query($conn,$query);
if($result)
{
echo"<script>alert('Ok');location.replace('floor.php?');</script>";
}
}
?>
<html>
<body>
<center>
<table border cellpadding="10" cellspacing="10">
<form name="frm" method="POST">
<tr>
<td>
Floor No
</td>
<td>:
</td>
<td><input type="text" name="floor_no"></td>
</tr>
<tr>
<td>
Floor Name
</td>
<td>
:
</td>
<td>
<input type="text" name="floor_name">
</td>
</tr>
<td>
Floor Status
</td>
<td>:</td>
<td><select name="status">
<option value=1>Available</option>
<option value=0>Unavailable</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit">
</td>
</tr>
</form>
</tr>
</table>
<br>
<table border cellpadding="10" cellspacing="10" width="70%">
<tr>
<td>Floor No</td>
<td size="12">Floor Name </td>
<td>Floor Status </td>
</tr>
<?php
$query="select * from floor_info order by floor_no";
$result=mysqli_query($conn,$query);
if($result)
{
while($data=mysqli_fetch_assoc($result))
{
if(isset($_GET['edit']) && $_GET['edit']==$data['floor_id'])
{
$available='';
$unavailable='';
if($data['floor_status']==1)
$available='selected';
else
$unavailable='selected';
?>
<tr>
<form name="frm2" method="POST">
<td><input type="text" name="floor_no_e" size="2" value="<?php echo $data['floor_no'];?>"><input type="hidden"name="floor_id_e"value="<?php echo $data['floor_id'];?>"></td>
<td><input type="text" name="floor_name_e" size="8" value="<?php echo $data['floor_name'];?>"></td>
<td><select name="status_e"><option value=0 <?php echo $unavailable;?>>Unavailable</option>
<option value=1 <?php echo $available;?>>Available</option>
</select></td>
<td><input type="submit" name="submit_e"></td>
<td><a href="floor.php?">Cancel</a></td>
</form>
</tr>
<?php
}
else
{
?>
<tr>
<td><?php echo $data['floor_no'];?></td>
<td><?php echo $data['floor_name'];?></td>
<td><?php echo $status=($data['floor_status']==0) ? "unavailable" : "available";?></td>
<td><a href="floor.php?uid=<?php echo $data['floor_id']?>">Delete</a></td>
<td><a href="floor.php?edit=<?php echo $data['floor_id']?>">Edit</a></td>
</tr>
<?php
}
}
}
?>
</table>
</center>
</body>
</html>