Hydrase

DISPLAY STUDENT1 IN TABLE FORM

Mar 4th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Student Records</title>
  6. </head>
  7. <body>
  8. <?php
  9. $conn = mysqli_connect("localhost", "root", "", "COLLEGE");
  10. if ($conn->connect_error) {
  11. die("Connection Failed: " . $conn->connect_error);
  12. }
  13. echo "Connected successfully<br>";
  14.  
  15. $sql = "SELECT SID, NAME, EMAIL, FEES, DOB FROM STUDENT";
  16. $result = mysqli_query($conn, $sql);
  17.  
  18. if (mysqli_num_rows($result) > 0) {
  19. // Output data for each row
  20. echo "<table border='1'>
  21. <tr>
  22. <th>ID</th>
  23. <th>NAME</th>
  24. <th>EMAIL</th>
  25. <th>FEES</th>
  26. <th>DOB</th>
  27. </tr>";
  28. while ($row = mysqli_fetch_assoc($result)) {
  29. echo "<tr>
  30. <td>" . $row["SID"] . "</td>
  31. <td>" . $row["NAME"] . "</td>
  32. <td>" . $row["EMAIL"] . "</td>
  33. <td>" . $row["FEES"] . "</td>
  34. <td>" . $row["DOB"] . "</td>
  35. </tr>";
  36. }
  37. echo "</table>"; // Closing table tag was missing
  38. } else {
  39. echo "0 results";
  40. }
  41.  
  42. $conn->close();
  43. ?>
  44. </body>
  45. </html>
  46.  
Add Comment
Please, Sign In to add comment