/
prob5.php
91 lines (79 loc) · 2.08 KB
/
prob5.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
<?php
include 'functions.php';
$title = "Problem 5 | WDIM361 Midterm";
$page_title = "WDIM361 Midterm - Problem 5";
$page_name = "WDIM361 Server-side Scripting 1 Midterm";
include '_header.php';
$people_stats = array(
'Bob' => array(
'age' => 50,
'music' => 'Hard Rock',
'relationship' => 'Friend'
),
'Bill' => array(
'age' => 20,
'music' => 'Heavy Metal',
'relationship' => 'Enemy'
),
'Mary' => array(
'age' => 3,
'music' => 'Teletubbies songs',
'relationship' => 'Ankle Bitter'
),
'Lestat' => array(
'age' => 5560,
'music' => 'Classical',
'relationship' => 'Fictional Character'
),
'Louie' => array(
'age' => 523,
'music' => 'Opera',
'relationship' => 'Vampire'
),
'Chris' => array(
'age' => 13,
'music' => 'Tween Wave',
'relationship' => 'Annoying Nephew'
),
'Xander' => array(
'age' => 37,
'music' => 'Video Game Theme Music',
'relationship' => 'Cartoon Character'
),
'Benjamin'=> array(
'age' => 39,
'music' => 'Gothic and Industrial',
'relationship' => 'Me'
)
);
// Build the table header
$table = <<<EOT
<h2>Table of People I um... know</h2>
<table border="1">
<thead>
<tr>
<td>Name</td>
<td>Age</td>
<td>Musical Taste</td>
<td>Relationship</td>
</tr>
</thead>
<tbody>
EOT;
// Populate the table rows
foreach ($people_stats as $person => $stats) {
// Start a new row and populate the person's name
$table .= "<tr><td>$person</td>";
// populate the rest to the person's stats
foreach ($stats as $stat => $value) {
$table .= "<td>$value</td>";
}
// End the row
$table .= "</tr>";
}
// Close the table
$table .= "</tbody>";
// Output the table
echo $table;
?>
<?php include '_footer.php'; ?>