Skip to content
Snippets Groups Projects
Commit db480511 authored by Alexander Jason's avatar Alexander Jason
Browse files

feat: audio

parent 0394aaf0
No related merge requests found
...@@ -148,6 +148,19 @@ class UserModel { ...@@ -148,6 +148,19 @@ class UserModel {
return $user; return $user;
} }
public function getMyBook($username){
$sql ="SELECT b.book_id
FROM book b JOIN have h ON b.book_id = h.book_id
JOIN user u ON h.username = u.username
WHERE u.username = ?";
$stmt = $this->db->prepare($sql);
$this->db->bindParams($stmt, "s", $username);
$this->db->execute($stmt);
$books = $this->db->getAllRecords($stmt);
$stmt->close();
return $books;
}
public function getTotalPages($perPage) { public function getTotalPages($perPage) {
$sql = "SELECT COUNT(*) FROM user"; $sql = "SELECT COUNT(*) FROM user";
......
...@@ -35,6 +35,25 @@ ...@@ -35,6 +35,25 @@
<!-- Decription --> <!-- Decription -->
<p> <?=$this->data['summary']?></p> <p> <?=$this->data['summary']?></p>
<!-- check ownership -->
<?php
$bookIdToCheck = $this->data['book_id'];
$found = false;
foreach ($this->data['own'] as $ownedBook) {
if (isset($ownedBook['book_id']) && $ownedBook['book_id'] == $bookIdToCheck) {
$found = true;
break;
}
}
if($found):
?>
<audio controls>
<source src="<?= BASE_URL ?>/<?= str_replace('/var/www/html/config/', '', $this->data['audio_path']) ?>" alt ="book-audio" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<?php endif; ?>
</div> </div>
<?php else : ?> <?php else : ?>
<h2 class="info">Can't find the book you're looking for!</h2> <h2 class="info">Can't find the book you're looking for!</h2>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment