From 39a0854c46539bf3269324e7643dbac9d4078e50 Mon Sep 17 00:00:00 2001
From: First <kv9.net@gmail.com>
Date: Sat, 29 Mar 2025 16:29:18 +0700
Subject: [PATCH] Edit index.php

---
 index.php | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/index.php b/index.php
index 6d4fafb..285b9c0 100644
--- a/index.php
+++ b/index.php
@@ -1,3 +1,28 @@
 <?php
-echo "65160381 Parinya Triyakun"
+
+$servername = "db";
+$username = "lab2-65160381";
+$password = "mark254421.";
+$dbname = "lab2-65160381";
+
+// Create connection
+$conn = new mysqli($servername, $username, $password, $dbname);
+
+// Check connection
+if ($conn->connect_error) {
+  die("Connection failed: " . $conn->connect_error);
+}
+
+$sql = "SELECT * 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"]. " - Score: " . $row["score"]."<br>";
+  }
+} else {
+  echo "0 results";
+}
+$conn->close();
 ?>
-- 
GitLab