D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
view_books.php
back
Copy
<?php // Database connection parameters $servername = "localhost"; $username = "markniuj_bazmpbto"; $password = "BC)1at0Y8Wa{"; $dbname = "markniuj_bazmpbto_november-2023"; // Establish a database connection $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $conn->set_charset("utf8mb4"); // Fetch books from the database $sql = "SELECT title, author, pdf_link, thumbnail, description FROM books ORDER BY id DESC"; $result = $conn->query($sql); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Books Collection</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container mt-5"> <h2 class="text-center mb-4">Books Collection</h2> <div class="row"> <?php if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { ?> <div class="col-md-4 mb-4"> <div class="card h-100"> <img src="<?php echo htmlspecialchars($row['thumbnail']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($row['title']); ?>" style="height: 250px; object-fit: cover;"> <div class="card-body"> <h5 class="card-title"><?php echo htmlspecialchars($row['title']); ?></h5> <p class="card-text"><strong>Author:</strong> <?php echo htmlspecialchars($row['author']); ?></p> <p class="card-text"><?php echo htmlspecialchars($row['description']); ?></p> </div> <div class="card-footer text-center"> <a href="<?php echo htmlspecialchars($row['pdf_link']); ?>" class="btn btn-primary" download>Download</a> <a href="<?php echo htmlspecialchars($row['pdf_link']); ?>" class="btn btn-secondary" target="_blank">Read Online</a> </div> </div> </div> <?php } } else { echo "<p class='text-center'>No books available.</p>"; } $conn->close(); ?> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>