-
Notifications
You must be signed in to change notification settings - Fork 0
/
publisher_list.php
49 lines (47 loc) · 1.18 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
<?php
session_start();
require_once "./functions/database_functions.php";
$conn = db_connect();
$query = "SELECT * FROM publisher ORDER BY publisherid";
$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}
if(mysqli_num_rows($result) == 0){
echo "Empty publisher ! Something wrong! check again";
exit;
}
$title = "List Of Publishers";
require "./template/header.php";
?>
<p class="lead">List of Publisher</p>
<ul>
<?php
while($row = mysqli_fetch_assoc($result)){
$count = 0;
$query = "SELECT publisherid FROM books";
$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"><?php echo $count; ?></span>
<a href="bookPerPub.php?pubid=<?php echo $row['publisherid']; ?>"><?php echo $row['publisher_name']; ?></a>
</li>
<?php } ?>
<li>
<a href="books.php">List full of books</a>
</li>
</ul>
<?php
mysqli_close($conn);
require "./template/footer.php";
?>