-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroomlist.php
102 lines (91 loc) · 2.45 KB
/
roomlist.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
<?php
include_once("header.php");
include_once("navbar.php");
?>
<html>
<head>
<style>
body {
background-image: url();
background-color: white;
}
th {
text-align: center;
}
tr {
height: 30px;
}
td {
padding-top: 5px;
padding-left: 20px;
padding-bottom: 5px;
height: 20px;
}
</body>
</style>
</head>
<body><br>
<div class="container">
<body>
<?php
echo "<tr>
<td>";
// your database connection
$host = "localhost";
$username = "root";
$password = "";
$database = "insertion";
// select database
mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
$query = ("SELECT * FROM rooms");
$result = mysql_query($query) or die(mysql_error());
echo "<div class='container'><table width='' class='table table-bordered' border='1' >
<tr>
<th>Rooms</th>
<th>Action</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['room'] . "</td>";
echo "<td><form class='form-horizontal' method='post' action='roomlist.php'>
<input name='id' type='hidden' value='".$row['id']."';>
<input type='submit' class='btn btn-danger' name='delete' value='Delete'>
</form></td>";
echo "</tr>";
}
echo "</table>";
echo "</td>
</tr>";
// delete record
if($_SERVER['REQUEST_METHOD'] == "POST")
{
echo '<script type="text/javascript">
alert("Schedule Successfuly Deleted");
location="tablelist.php";
</script>';
}
if(isset($_POST['id']))
{
$id = mysql_real_escape_string($_POST['id']);
$sql = mysql_query("DELETE FROM rooms WHERE id='$id'");
if(!$sql)
{
echo ("Could not delete rows" .mysql_error());
}
}
?>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "footer.php";
include_once("footer.php");
?>