Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- <table style="border: solid black 2px">
- <th>Id</th>
- <th>Name</th>
- <th>School</th>
- <?php
- $servername = "localhost";
- $username = "kotlarovmiroslav";
- $password = "1234";
- $dbname = "myDB";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM students";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<tr>";
- echo "<td>" .$row["id"] ."</td>";
- echo "<td>" .$row["name"] ."</td>";
- echo "<td>" .$row["school"] ."</td>";
- echo "</tr>";
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement