Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = "localhost";
- $username = "testuser2024";
- $password = "testuser";
- $db = "testuser2024_TestDbase";
- $conn = mysqli_connect ($server, $username, $password, $db);
- // I can remove this check...it serves no purpose now.
- //if (!$conn) {
- // die("connection failed: " . mysqli_connect_error());
- //
- //}
- //echo("connected successfully homieG");
- $query = mysqli_query($conn, "Select Student_ID, Surname, Age from Student_details") or die(mysql_error($conn));
- echo("<table border=\"1\">"); //this puts a border around the data using line thickness of 1
- echo("<tr> <td>ID</td> <td>Surname</td> <td>Age</td> </tr>"); //this put column headings in <td> = cell
- while ($row = mysqli_fetch_array($query)) {
- printf("<tr> <td>%s</td> <td>%s</td> <td>%s</td> </tr>", $row['Student_ID'], $row['Surname'], $row['Age']);
- //%s essentially means grab the value from the SQL table and insert it here. Try leaving the %s out and see what happens :)
- }
- echo("</table>");
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement