-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaclist.php
105 lines (93 loc) · 2.67 KB
/
faclist.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
<?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 faculty");
$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>Designation</th>
<th>Action</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['faculty_name'] . "</td>";
echo "<td>" . $row['designation'] . "</td>";
echo "<td><form class='form-horizontal' method='post' action='faclist.php'>
<input name='faculty_id' type='hidden' value='".$row['faculty_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("row Successfuly Deleted");
location="list.php";
</script>';
}
if(isset($_POST['faculty_id']))
{
$faculty_id = mysql_real_escape_string($_POST['faculty_id']);
$sql = mysql_query("DELETE FROM faculty WHERE faculty_id='$faculty_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");
?>