-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.php
72 lines (54 loc) · 1.72 KB
/
list.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
<?php session_start();
include 'connect.php'; //contains the values of the variables $host $dbname $user and $password
$con = pg_connect("host='" . $host . "' dbname='" . $dbname . "' user='" . $user . "' password='" . $password . "'");
if (!$con)
{
die("Could not connect: " . pg_last_error());
}
include('header.php');
include('functions.php');
if ( isset($_REQUEST['action']) ) {
switch ($_REQUEST['action'])
{
case "delete":
$sql = "DELETE FROM info WHERE pid = '" . $_REQUEST['pid'] . "';";
$sql .= "DELETE FROM hours WHERE pid = '" . $_REQUEST['pid'] . "';";
pg_query($sql);
// echo $sql;
if (isset($_SESSION['msg']))
$_SESSION['msg'] .= "Deleted user<br>";
else
$_SESSION['msg'] = "Deleted user<br>";
break;
}
}
echo "<h1>Scheduling Management</h1>";
if ( isset($_SESSION['msg']) ) {
echo "<br />" . $_SESSION['msg'];
$_SESSION['msg'] = "";
}
echo '<a href="manage.php">Return</a>';
$sql = 'SELECT * from info;';
$resource = pg_fetch_all(pg_query($sql));
//Print headers
echo "<table border='1'><tr>";
$keys = array_keys($resource[0]);
foreach ($keys as $value){
echo "<th>" . $value . "</th>";
}
echo "</tr>\n";
//Print data
foreach($resource as $array){
echo "<tr>";
foreach($array as $value){
echo "<td>" . $value . "</td>";
}
echo "<td>";
?>
<a class="ico-delete"href="?action=delete&pid=<?php echo $array['pid'];?>">Delete</a>
<?php
echo "</tr>\n";
}
echo "</table>\n";
include('footer.php');
?>