-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublisher_list.php
65 lines (53 loc) · 1.93 KB
/
publisher_list.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
<?php
session_start();
require_once "./functions/database_functions.php";
$conn = db_connect();
$query = "SELECT * FROM publisher ORDER BY publisherid";
//$query = "SELECT * FROM publisher ORDER BY rand()";
$result = mysqli_query($conn, $query);
if (!$result) {
$errorMessage = $_SESSION["errorArray"]["retrieveFailed"] = "Cannot Retrieve Data";
header("Location : nothingFound.php");
exit;
}
if (mysqli_num_rows($result) == 0) {
echo "Empty publisher ! Something wrong! check again";
exit;
}
$title = "List Of Publishers";
require "./template/header.php";
?>
<div class="container">
<p class="lead big-font-5 heading-hover text-center">Publishers List</p>
<ul class="publisher-list">
<?php
while ($row = mysqli_fetch_assoc($result)) {
$count = 0;
$query = "SELECT publisherid FROM books";
// $query = "SELECT publisherid FROM books ORDER BY rand()";
$result2 = mysqli_query($conn, $query);
if (!$result2) {
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}
while ($pubInBook = mysqli_fetch_assoc($result2)) {
if ($pubInBook['publisherid'] == $row['publisherid']) {
$count++;
}
}
?>
<li>
<span class="badge style-badge"><?php echo $count; ?></span>
<a class="text-primary big-font-1 text-primary"
href="bookPerPub.php?pubid=<?php echo $row['publisherid']; ?>"><?php echo $row['publisher_name']; ?></a>
</li>
<?php } ?>
<li>
<a class="btn btn-primary margin-top-bottom-3" href="books.php">Books List</a>
</li>
</ul>
</div>
<?php
mysqli_close($conn);
require "./template/footer.php";
?>