Untitled
unknown
plain_text
5 months ago
1.5 kB
3
Indexable
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "hotel_registration"; $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM registrations"; $result = $conn->query($sql); ?> <!DOCTYPE html> <html lang="en"> <head> <title>Hotel Registration Details</title> <style> table { width: 100%; border-collapse: collapse; } table, th, td { border: 1px solid black; } th, td { padding: 10px; text-align: left; } h1 { text-align: center; } </style> </head> <body> <h1>Hotel Registration Information</h1> <?php // Check if there are any records if ($result->num_rows > 0) { // Start the HTML table echo "<table> <tr> <th>ID</th> <th>Full Name</th> <th>Email</th> <th>Phone</th> <th>Check In</th> <th>Check Out</th> <th>Room Type</th> <th>Special Requests</th> </tr>"; // Fetch and display each row of data while ($row = $result->fetch_assoc()) { echo "<tr> <td>" . $row["id"] . "</td> <td>" . $row["full_name"] . "</td> <td>" . $row["email"] . "</td> <td>" . $row["phone"] . "</td> <td>" . $row["check_in"] . "</td> <td>" . $row["check_out"] . "</td> <td>" . $row["room_type"] . "</td> <td>" . $row["special_requests"] . "</td> </tr>"; } echo "</table>"; } else { echo "<p>Nuk u gjend asnje rresht !.</p>"; } $conn->close(); ?> </body> </html>
Editor is loading...
Leave a Comment