Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 1c43e53c authored by 65160264's avatar 65160264
Browse files

connect index.php

parent 25a319e2
No related branches found
No related tags found
No related merge requests found
<?php echo "Ruk buaruang 65160264"; <?php
echo "Ruk buaruang 65160264";
$servername = "db";
$username = "Lab2";
$password = "Ruk241246<3";
$dbname = "Lab2";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, fname, lname FROM student";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["fname"]. " " . $row["lname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment