Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type"'.' content="text/html; charset=utf-8"/>
- </head>
- <style>
- table {
- width: 100%;
- border-collapse: collapse;
- }
- table, td, th {
- border: 1px solid black;
- padding: 5px;
- }
- th {text-align: left;}
- </style>
- </head>
- <body>
- <?php
- header("Content-Type: text/html; charset=utf-8");
- $username="my_username";
- $password="my_password";
- $database="my_database";
- $conn = new mysqli(localhost, $username, $password, $database);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql="SELECT * FROM words";
- $result = $conn->query($sql);
- echo "<table>
- <tr>
- <th>Character</th>
- <th>Pinyin</th>
- <th>English</th>
- <th>category</th>
- <th>lesson</th>
- </tr>";
- while($row = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>" . $row['char_word'] . "</td>";
- echo "<td>" . $row['pinyin_word'] . "</td>";
- echo "<td>" . $row['english_word'] . "</td>";
- echo "<td>" . $row['category'] . "</td>";
- echo "<td>" . $row['lesson'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- mysqli_close($con);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement