📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
Automation
Dosya Düzenle: book.php
<?php include 'connect.php'; ?> <!DOCTYPE html> <html> <head> <title>Book Allocation</title> <style> body { font-family: Arial; background:#f4f4f4; } h2 { text-align:center; } table { border-collapse: collapse; width: 100%; background:#fff; } th, td { border: 1px solid #ccc; padding: 8px; text-align: center; } th { background:#222; color:white; } input { padding:5px; width:120px; } button { padding:5px 10px; cursor:pointer; } .full { background:red; color:white; } </style> </head> <body> <h2>📚 Book Allocation System</h2> <table> <tr> <th>Book Name</th> <th>Author</th> <th>Group</th> <th>Qty</th> <th>Price</th> <th>Alloted Students</th> <th>Available</th> <th>Action</th> </tr> <?php $result = $conn->query("SELECT * FROM books"); while ($row = $result->fetch_assoc()) { $book_id = $row['id']; // Get students $students = $conn->query("SELECT student_name FROM bookings WHERE book_id=$book_id"); $student_names = []; while ($s = $students->fetch_assoc()) { $student_names[] = $s['student_name']; } $booked = count($student_names); $available = $row['qty'] - $booked; ?> <tr> <td><?= $row['book_name'] ?></td> <td><?= $row['author'] ?></td> <td><?= $row['book_group'] ?></td> <td><?= $row['qty'] ?></td> <td>₹<?= $row['price'] ?></td> <!-- Alloted Students --> <td> <?= $booked > 0 ? implode("<br>", $student_names) : "None"; ?> </td> <!-- Available --> <td><?= $available ?></td> <!-- Booking --> <td> <?php if ($available > 0) { ?> <form method="POST" action="book_submit.php"> <input type="hidden" name="book_id" value="<?= $book_id ?>"> <input type="text" name="student_name" placeholder="Your Name" required> <button type="submit">Book</button> </form> <?php } else { ?> <button class="full" disabled>Full</button> <?php } ?> </td> </tr> <?php } ?> </table> </body> </html>
💾 Kaydet
İptal