-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtablelist.php
100 lines (91 loc) · 2.99 KB
/
tablelist.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
<?php
include_once("header.php");
include_once("navbar.php");
?>
<html>
<head>
</head>
<body><br>
<div align="center">
<fieldset>
<legend>Schedule</legend>
<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 addtable");
$result = mysql_query($query) or die(mysql_error());
echo "<div class='container'><table width='' class='table table-bordered' border='1' >
<tr>
<th>Faculty</th>
<th>Course</th>
<th>Subject</th>
<th>Room</th>
<th>Building</th>
<th>Start time</th>
<th>End time</th>
<th>Action</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['faculty'] . "</td>";
echo "<td>" . $row['course'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['room'] . "</td>";
echo "<td>" . $row['building'] . "</td>";
echo "<td>" . $row['start_time'] . "</td>";
echo "<td>" . $row['end_time'] . "</td>";
echo "<td><form class='form-horizontal' method='post' action='tablelist.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 addtable WHERE id='$id'");
if(!$sql)
{
echo ("Could not delete rows" .mysql_error());
}
}
?>
</fieldset>
</form>
</div>
</div>
</div>
<div align="center">
<br>
<a href="home.php"><input type='submit' class='btn btn-success' name='delete' value='New'></a>
<a href="Index.php"><input type='submit' class='btn btn-primary' name='delete' value='Logout'></a>
</div>
</div>
</body>
</html>
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "footer.php";
include_once("footer.php");
?>