-
Notifications
You must be signed in to change notification settings - Fork 77
/
index.php
52 lines (49 loc) · 1.55 KB
/
index.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
function printArrayValuesAsTableRow(array $a)
{
foreach($a as $key => $value)
{
echo("<td name='" . $key . "'>" . $value . "</td>\n");
}
}
function printPeopleArrayAsTableContents(array $a)
{
foreach($a as $value)
{
echo("<tr>\n");
printArrayValuesAsTableRow($value);
echo("<td><button onclick=\"alert('Name: " . $value["first_name"] . " " . $value["last_name"] . "\nEmail: " . $value["email"] . "');\">Alert</button></td>\n");
echo("</tr>\n");
}
}
$people = array(
array('id'=>1, 'first_name'=>'John', 'last_name'=>'Smith', 'email'=>'[email protected]'),
array('id'=>2, 'first_name'=>'Paul', 'last_name'=>'Allen', 'email'=>'[email protected]'),
array('id'=>3, 'first_name'=>'James', 'last_name'=>'Johnston', 'email'=>'[email protected]'),
array('id'=>4, 'first_name'=>'Steve', 'last_name'=>'Buscemi', 'email'=>'[email protected]'),
array('id'=>5, 'first_name'=>'Doug', 'last_name'=>'Simons', 'email'=>'[email protected]')
);
?>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<main>
<table>
<thead>
<td>ID</td>
<td>First Name</td>
<td>Last Name</td>
<td>Email</td>
<td>Button</td>
</thead>
<tbody>
<?php
printPeopleArrayAsTableContents($people)
?>
</tbody>
</table>
</main>
</body>