-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewProjects.php
More file actions
executable file
·118 lines (110 loc) · 3.82 KB
/
viewProjects.php
File metadata and controls
executable file
·118 lines (110 loc) · 3.82 KB
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
<?php
session_start();
// Include config file
require_once "config.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>View Projects</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<style type="text/css">
.wrapper{
width: 650px;
margin: 0 auto;
}
.page-header h2{
margin-top: 0;
}
table tr td:last-child a{
margin-right: 15px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header clearfix">
<h2 class="pull-left">View Projects</h2>
<a href="addProject.php" class="btn btn-success pull-right">Add Project</a>
</div>
<?php
// Check existence of id parameter before processing further
if(isset($_GET["Ssn"]) && !empty(trim($_GET["Ssn"]))){
$_SESSION["Ssn"] = $_GET["Ssn"];
}
if(isset($_GET["Lname"]) && !empty(trim($_GET["Lname"]))){
$_SESSION["Lname"] = $_GET["Lname"];
}
if(isset($_SESSION["Ssn"]) ){
// Prepare a select statement
$sql = "SELECT P.Pname, P.Pnumber, WO.Hours, WO.Essn FROM PROJECT P, WORKS_ON WO WHERE WO.Essn = ? AND WO.Pno = P.Pnumber";
//$sql = "SELECT Essn, Pno, Hours From WORKS_ON WHERE Essn = ? ";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_Ssn);
// Set parameters
$param_Ssn = $_SESSION["Ssn"];
$Lname = $_SESSION["Lname"];
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
$result = mysqli_stmt_get_result($stmt);
echo"<h4> Projects for ".$Lname."   SSN =".$param_Ssn."</h4><p>";
if(mysqli_num_rows($result) > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th width = 20%>Project Number</th>";
echo "<th>Project Name</th>";
echo "<th>Hours</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
// output data of each row
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Pnumber'] . "</td>";
echo "<td>" . $row['Pname'] . "</td>";
echo "<td>" . $row['Hours'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
mysqli_free_result($result);
} else {
echo "No Projects. ";
}
// mysqli_free_result($result);
} else{
// URL doesn't contain valid id parameter. Redirect to error page
header("location: error.php");
exit();
}
}
// Close statement
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($link);
} else{
// URL doesn't contain id parameter. Redirect to error page
header("location: error.php");
exit();
}
?>
<p><a href="index.php" class="btn btn-primary">Back</a></p>
</div>
</div>
</div>
</div>
</body>
</html>