-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
82 lines (82 loc) · 3.1 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
require_once($path . "/head.php");
?>
<title>PeopleDB</title>
<meta name="description" content="PeopleDB">
<link rel="canonical" href="http://peopledb.localhost">
<meta property="og:title" content="PeopleDB"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://peopledb.localhost"/>
<meta property="og:image" content="/global/site-files/peopledb-logo.png"/>
<meta property="og:description" content="PeopleDB"/>
</head>
<body id="site">
<?php
require_once($path . "/header.php");
?>
<div id="content">
<div id="add-person">
<a href="/person/edit.php" class="btn btn-primary">Add person</a>
</div>
<div id="search-results">
<table id="personsTable" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th class="td-image">Photo</th>
<th>Last Name</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Nickname</th>
<th>Acquaintance type</th>
<th>Alternative names</th>
</tr>
</thead>
<tbody>
<?php
require_once($path . "/connection.php");
$result = mysqli_query($link, "SELECT * FROM person");
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr onclick='window.open("/person/index.php?id=<?php echo $row['id'] ?>", "_blank");'>
<td> <?php echo $row['id'] ?></td>
<td class="td-image">
<?php if (file_exists($path . "/images/" . $row['id'] . "/0.jpg")) { ?>
<img src="/images/<?php echo $row['id'] ?>/0.jpg" loading="lazy"
alt="<?php echo $row['last_name'] ?> <?php echo $row['first_name'] ?> photo">
<?php } ?>
</td>
<td> <?php echo $row['last_name'] ?></td>
<td> <?php echo $row['first_name'] ?></td>
<td> <?php echo $row['middle_name'] ?></td>
<td> <?php echo $row['nickname'] ?></td>
<td> <?php echo $row['acquaintance_type'] ?></td>
<td>
<?php
$sub_result = mysqli_query($link,
"SELECT * FROM alternative_last_names WHERE person_id=" . $row['id']);
$alternative_names = array();
while ($sub_row = mysqli_fetch_array($sub_result)) {
$alternative_names[] = $sub_row['last_name'];
}
echo implode(", ", $alternative_names);
?>
</td>
</tr>
<?php
}
mysqli_close($link);
?>
</tbody>
</table>
</div>
</div>
<?php
require_once($path . "/footer.php");
?>
</body>
</html>