-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauthors.php
71 lines (63 loc) · 1.96 KB
/
authors.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
<?php
require_once("scripts/directory.php");
require_once("scripts/login.php");
require_once("scripts/error.php");
require_once("scripts/start.php");
$listBullet = "fa-chevron-circle-right";
startPage("authors");
$connection = new mysqli($db_hostname, $db_username, $db_password, $db_database);
if($connection->connect_errno) {
echo "<div class='main'>";
$error = getErrorString("Could not connect to the database.", $connection->connect_errno);
echo $error;
echo "</div>";
exit();
}
echo "<a href='#bottom' class='to-bottom'><i class='fa fa-arrow-circle-down'></i></a>";
echo "<a href='#top' class='to-up'><i class='fa fa-arrow-circle-up'></i></a>";
echo "<a href='#bottom' class='to-bottom'><i class='fa fa-arrow-circle-down'></i></a>";
echo "<div id='top'></div>";
echo "<div class='main'>";
echo "<div class='frame' style='text-align: left;'>";
echo "<div class='container'>";
echo <<<EOF
<div class='frame-head'>
<p>Authors</p>
<div class='underline active black'></div>
</div>
EOF;
$sql = "SELECT * FROM authors ORDER BY author ASC";
$result = $connection->query($sql);
if(!$result) {
$error = getErrorString("Query unsuccessful", $connection->errno);
$connection->close();
die($error);
}
$rows = $result->num_rows;
if($rows > 0) {
$sectionLetter = '';
echo "<ul class='fa-ul'>";
while($row = $result->fetch_assoc()) {
$author = $row['author'];
$authorId = $row['authorId'];
$letter = $author[0];
if($letter !== $sectionLetter) {
$sectionLetter = $letter;
echo "<div class='author-list-letter'>$sectionLetter</div>";
echo "<div class='bookmark-hanger'></div>";
}
$data = array(
'author' => $authorId
);
$url = "byauthor.php?" . http_build_query($data);
echo "<li class='authors-all'><a class='authors-link' href='$url'><span class='fa-li'><i class='fas $listBullet'></i></span>$author</a></li>";
}
echo "</ul>";
echo "<div id='bottom'></div>";
}
else {
$error = getErrorString("No authors found", 0);
echo $error;
}
echo "</div>";
echo "</div>";