<!
DOCTYPE html>
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h2>Employee Details</h2>
<?php
// Database connection
$conn = new mysqli("localhost", "root", "", "mydata");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SQL query
$sql = "SELECT id, name, depart, tell, salary, score FROM emp";
$result = $conn->query($sql);
// Check if data exists
if ($result->num_rows > 0) {
echo "<table border='1'>";
echo "<tr>
<th>ID</th>
<th>Name</th>
<th>Department</th>
<th>Telephone</th>
<th>Salary</th>
<th>Score</th>
</tr>";
// Fetch and display rows
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['depart']."</td>
<td>".$row['tell']."</td>
<td>".$row['salary']."</td>
<td>".$row['score']."</td>
</tr>";
}
echo "</table>";
} else {
echo "No records found.";
}
// Close connection
$conn->close();
?>
</body>
</html>