Advertisement
Guest User

Untitled

a guest
Feb 27th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "tech_project";
  6.  
  7. $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
  8. //* Check connection
  9. if (mysqli_connect_errno())
  10. {
  11. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  12. }
  13.  
  14. $result = mysqli_query($conn,"SELECT * FROM emp_details");
  15.  
  16. echo "<table border='1'>
  17. <tr>
  18. <th>Name</th>
  19. <th>Email</th>
  20. <th>Gender</th>
  21. <th>Address</th>
  22. <th>City</th>
  23. </tr>";
  24.  
  25. while($row = mysqli_fetch_array($result))
  26. {
  27. echo "<tr>";
  28. echo "<td>" . $row['name'] . "</td>";
  29. echo "<td>" . $row['email'] . "</td>";
  30. echo "<td>" . $row['gender'] . "</td>";
  31. echo "<td>" . $row['address'] . "</td>";
  32. echo "<td>" . $row['city'] . "</td>";
  33. echo "</tr>";
  34. }
  35. echo "</table>";
  36.  
  37. mysqli_close($conn);
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement