Guest User

Untitled

a guest
Oct 5th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "jit123";
  5. $dbname = "1jt14cs018db3";
  6.  
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8.  
  9. if ($conn->connect_error)
  10. {
  11. die("connection failed: " . $conn->connect_error);
  12. }
  13. else
  14. {
  15. $sqlQuery = "select * from student";
  16. $result = $conn->query($sqlQuery);
  17. if($result->num_rows > 0)
  18. {
  19. echo "<table align=\"center\"border=1><tr><th>student regno</th>";
  20. echo "<th>Student Name</th>";
  21. echo "<th>major</th>";
  22. echo "<th>DOB</th>";
  23. echo "</tr>";
  24. while($row = $result->fetch_assoc())
  25. {
  26. echo"<tr>";
  27. echo "<td>$row[regno]</td>";
  28. echo"<td>$row[name]</td>";
  29. echo"<td>$row[major]</td>";
  30. echo"<td>$row[bdate]</td>";
  31. echo "</tr>";
  32. }
  33. echo "</table>";
  34. }
  35. else
  36. echo"Empty set";
  37. }
  38. $conn->close();
  39. ?>
Add Comment
Please, Sign In to add comment