Files
php-db-question/answer/Ex02.php
2026-10-28 16:53:31 +09:00

48 lines
1.5 KiB
PHP

<?php
// Ex02.php - 表示用ファイル
require_once __DIR__ . '/Ex02_query.php';
$employees = getEmployees();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Employees List</title>
<link href="../common/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Employees List</h1>
<?php if (!empty($employees)): ?>
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>従業員ID</th>
<th>プロジェクトID</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<?php foreach ($employees as $emp): ?>
<tr>
<td><?php echo htmlspecialchars($emp['id']); ?></td>
<td><?php echo htmlspecialchars($emp['name']); ?></td>
<td><?php echo htmlspecialchars($emp['dep_id']); ?></td>
<td><?php echo htmlspecialchars($emp['project_id']); ?></td>
<td><?php echo htmlspecialchars($emp['salary']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p>No employee data found.</p>
<?php endif; ?>
</div>
</body>
</html>