/
Functions.php
108 lines (102 loc) · 2.44 KB
/
Functions.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
<?php
include ('func.php');
// require_once ('func.php'); //Require reports errors, include does not. Otherwise they are the same
// include_once and require work also, so does include_twice.
/**
* Created by PhpStorm.
* User: Ute
* Date: 9/10/2015
* Time: 8:06 PM
* Data Definitions go above HTML code
* according to Dave
*/
$companies[]= array (
"name" => "Madwire",
"address" => "550 West Eisenhower Blvd",
"city" => "Loveland",
"state" => "CO",
"zip" => "80537",
"employees" => array('david','joe','jb','jerry')
);
$companies[] = array(
"name" => "IBM",
"address" => "123 IBM Drive",
"city" => "Boulder",
"state" => "CO",
"zip" => "80301",
"employees" => array ('Joe', 'Tom')
);
$companies[] = array(
"name" => "HP",
"address" => "123 HP Drive",
"city" => "Fort Collins",
"state" => "CO",
"zip" => "80524",
"employees" => array ('Paul', 'John', 'Mike')
);
$companies[] = array(
"name" => "Digital Globe",
"address" => "123 DG Street",
"city" => "Longmont",
"state" => "CO",
"zip" => "80501",
"employees" => array ('Ute', 'James', 'Peter')
);
?>
<html>
<head>
<h1>Company Listings</h1>
</head>
<body>
<?php print "<pre>". print_r ($companies, true) . "</pre>"; ?>
<?php $TotalEmployees = 0; ?>
<table>
<tr>
<td>
Name
</td>
<td>
Address
</td>
<td>
City
</td>
<td>
Number of Employees
</td>
<td>
Employee Names
</td>
</tr>
<?php foreach ($companies as $company) { ?>
<tr>
<td><?php print $company ['name']; ?> </td>
<td><?php print $company ['address']; ?> </td>
<td> <?php print $company ['city']; ?> </td>
<?php $count = countEmployees ($company['employees']); ?>
<td><?php print $count;?> </td>
<?php $TotalEmployees += $count;?>
<td>
<?php foreach ($company['employees'] as $employee) {
print capName ($employee . " ");
} ?>
<?php } ?>
</td>
</tr>
</table>
<?php print "Total number of Employees: " .$TotalEmployees; ?>
<style>
table {width: 100%;}
td { border: 1px solid black}
</style>
</body>
</html>
<?php
/**
* Created by PhpStorm.
* User: Ute
* Date: 9/10/2015
* Time: 8:06 PM
* Functions go below HTML code
* according to Dave
*/