-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemp-preview.php
138 lines (104 loc) · 3.91 KB
/
emp-preview.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/*
NEW.PHP
Add data to 'employees' table
*/
// header
include('header.php');
// connect to the database
function empForm($employeeNumber, $lastName, $firstName, $extension, $email, $officeCode, $reportsTo, $jobTitle, $error)
{
// if there are any errors, display them
if ($error != '')
{
echo '<div class="alert alert-danger"> '.$error.'</div>';
}
?>
<div id="employees" class="section form-md-1">
<div class="fixed-wrapper"><h1>Employee Preview</h1></div>
<div class="container">
<div class="content">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="team-portrait block">
<div class="title">
<h2><?php echo $firstName; ?> <?php echo $lastName; ?></h2>
<h3 class="italic"><?php echo $jobTitle; ?></h3>
</div>
<div class="portrait">
<i class="icon-user"></i>
</div>
<div class="bs-callout bs-callout-info">
<?php
$result = mysql_query("SELECT officeCode, city, country FROM offices WHERE officeCode='$officeCode'")
or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
echo '<p><h4>Office Location:</h4> <i class="icon-building"></i> ' . $row['city'] . ', ' . $row['country'] . '</p>';
}
$result2 = mysql_query("SELECT employeeNumber, lastName, firstName FROM employees WHERE reportsTo='$reportsTo' LIMIT 1")
or die(mysql_error());
while ($row2 = mysql_fetch_array($result2)) {
echo '<p><h4>Reports To: </h4><i class="icon-user"></i> ' . $row2['lastName'] . ' ' . $row2['firstName'] . '</p>';
}
?>
</div>
<div class="social-media">
<a href="#" data-toggle="tooltip" title="extension"><i class="icon-phone"></i><?php echo $extension; ?></a>
<a href="mailto:<?php echo $email; ?>" data-toggle="tooltip" title="email"><i class="icon-envelope"></i><?php echo $email; ?></a>
<span class="stretch"></span>
</div>
</div>
</div>
</div>
<br />
</div>
</div><!-- /.container -->
<?php
}
include('linkupdb.php');
// get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
if (isset($_GET['employeeNumber']) && is_numeric($_GET['employeeNumber']) && $_GET['employeeNumber'] > 0)
{
// query db
$employeeNumber = $_GET['employeeNumber'];
$result = mysql_query("SELECT * FROM employees WHERE employeeNumber='$employeeNumber'")
or die(mysql_error());
$row = mysql_fetch_array($result);
// check that the 'id' matches up with a row in the database
if($row)
{
// get data from db
$employeeNumber = $row['employeeNumber'];
$lastName = $row['lastName'];
$firstName = $row['firstName'];
$extension = $row['extension'];
$email = $row['email'];
$officeCode = $row['officeCode'];
$reportsTo = $row['reportsTo'];
$jobTitle = $row['jobTitle'];
// show form
empForm($employeeNumber, $lastName, $firstName, $extension, $email, $officeCode, $reportsTo, $jobTitle, $error);
}
else
// if no match, display result
{
?>
<div class="jumbotron">
<h1>Unable to find Employee!</h1>
<p> <?php echo '<div class="alert alert-danger">Unable to find employee within the database </div>';?> </p>
</div>
<?php
}
}
else
// if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
{
?>
<div class="jumbotron">
<h1>Unable to find Employee!</h1>
<p> <?php echo '<div class="alert alert-danger">Unable to find employee within the database </div>';?> </p>
</div>
<?php
}
// footer
include('footer.php');
?>