Advertisement
Guest User

Untitled

a guest
Feb 27th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type"'.' content="text/html; charset=utf-8"/>
  5. </head>
  6. <style>
  7. table {
  8. width: 100%;
  9. border-collapse: collapse;
  10. }
  11.  
  12. table, td, th {
  13. border: 1px solid black;
  14. padding: 5px;
  15. }
  16.  
  17. th {text-align: left;}
  18. </style>
  19. </head>
  20. <body>
  21.  
  22. <?php
  23. header("Content-Type: text/html; charset=utf-8");
  24.  
  25. $username="my_username";
  26. $password="my_password";
  27. $database="my_database";
  28.  
  29. $conn = new mysqli(localhost, $username, $password, $database);
  30. // Check connection
  31. if ($conn->connect_error) {
  32. die("Connection failed: " . $conn->connect_error);
  33. }
  34.  
  35. $sql="SELECT * FROM words";
  36. $result = $conn->query($sql);
  37.  
  38.  
  39. echo "<table>
  40. <tr>
  41. <th>Character</th>
  42. <th>Pinyin</th>
  43. <th>English</th>
  44. <th>category</th>
  45. <th>lesson</th>
  46. </tr>";
  47. while($row = mysqli_fetch_array($result)) {
  48. echo "<tr>";
  49. echo "<td>" . $row['char_word'] . "</td>";
  50. echo "<td>" . $row['pinyin_word'] . "</td>";
  51. echo "<td>" . $row['english_word'] . "</td>";
  52. echo "<td>" . $row['category'] . "</td>";
  53. echo "<td>" . $row['lesson'] . "</td>";
  54. echo "</tr>";
  55. }
  56. echo "</table>";
  57. mysqli_close($con);
  58. ?>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement