-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_books.php
53 lines (45 loc) · 1.44 KB
/
fetch_books.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
<?php
$conn_id=1;
include('connect.php');
$limit = 6;
/*GET THE CURRENT PAGE NUM FROM GET LINK*/
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $limit;
/*FETCH BOOKS WITHIN LIMIT*/
$sql = "SELECT * FROM books LIMIT $start_from, $limit";
$rs_result = mysqli_query($conn, $sql);
$count=1;
while($row = $rs_result->fetch_assoc())
{
$id = $row["id"];
$author = $row["author"];
$title = $row["title"];
$genre_id = $row["genre_id"];
$price = $row["price"];
$discount_id = $row["discount"];
$pub_id = $row["pub_id"];
$edition = $row["edition"];
$new = $row["new"];
$cover = $row["cover"];
$encoded_image = base64_encode($cover);
$image = "<a href='view_book.php?book_id=$id'><img src='data:image/jpeg;base64,{$encoded_image}' class='cover_image' width=215 height=375></a>";
$col = <<<EOT
<div class="col-md-4">
<div class="row image">
$image
</div>
<div class="row title">
<p data-toggle="title p" data-placement="top" title="$title">
$title
</p>
</div>
<div class="row price">
<p>Rs. $price</p>
</div>
</div>
EOT;
/*DISPLAY BOOKS*/
echo $col;
$count++;
}
?>