-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
42 lines (35 loc) · 1.27 KB
/
Copy pathindex.php
File metadata and controls
42 lines (35 loc) · 1.27 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
<?php
function html_table($data = array())
{
$rows = array();
foreach ($data as $row) {
$cells = array();
foreach ($row as $key => $cell) {
$cells[] = "<td>{$cell}</td>";
if ($key=="first_name")
{
$first_name=$cell;
}
if ($key=="last_name")
{
$last_name=$cell;
}
if ($key=="email")
{
$email=$cell;
}
}
array_push($cells,"<td> <button class='btn' onClick=alert('Name:".$first_name.".".$last_name.str_repeat(' ', 5)."email:".$email."') >Button</button> </td>");
$rows[] = "<tr>" . implode('', $cells) . "</tr>";
}
return "<table class='hci-table'>" . implode('', $rows) . "</table>";
}
$people = array(
array('id'=>1, 'first_name'=>'John', 'last_name'=>'Smith', 'email'=>'john.smith@hotmail.com'),
array('id'=>2, 'first_name'=>'Paul', 'last_name'=>'Allen', 'email'=>'paul.allen@microsoft.com'),
array('id'=>3, 'first_name'=>'James', 'last_name'=>'Johnston', 'email'=>'james.johnston@gmail.com'),
array('id'=>4, 'first_name'=>'Steve', 'last_name'=>'Buscemi', 'email'=>'steve.buscemi@yahoo.com'),
array('id'=>5, 'first_name'=>'Doug', 'last_name'=>'Simons', 'email'=>'doug.simons@hotmail.com')
);
echo html_table($people);
?>