<?php
$biaoge=[
['id'=>1, 'name'=>'候亮平', 'age'=>30, 'sex'=>1, 'email'=>'hlp@php.cn', 'password'=>sha1('123456')],
['id'=>2, 'name'=>'高小琴', 'age'=>30, 'sex'=>1, 'email'=>'hlp@php.cn', 'password'=>sha1('123456')],
['id'=>3, 'name'=>'李达康', 'age'=>50, 'sex'=>1, 'email'=>'ldk@php.cn', 'password'=>sha1('123456')],
['id'=>4, 'name'=>'祁同伟', 'age'=>45, 'sex'=>1, 'email'=>'qtw@php.cn', 'password'=>sha1('123456')],
['id'=>5, 'name'=>'高小琴', 'age'=>30, 'sex'=>0, 'email'=>'gxq@php.cn', 'password'=>sha1('123456')],
];
$title = '用户信息表';
$total = count($biaoge);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?php echo "$title";?></title>
<style type="text/css">
table,td,th{
border: 1px solid red;
padding: 10px;
}
table{
border-collapse: collapse;
background: #ccc;
width: 80%;
margin: 30px auto;
text-align: center;
}
thead tr:first-of-type {
background-color: lightblue;
}
tbody tr:hover {
background-color: #efefef;
}
table>caption{
color: red;
margin: 10px auto;
text-align: center;
}
table+p{
text-align: center;
}
</style>
</head>
<body>
<table>
<caption><?php echo "$title"; ?></caption>
<thead>
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>邮箱</th>
<th>密码</th>
</tr>
</thead>
<tbody>
<?php
$date="";
foreach($biaoge as $staff){
$date.= '<tr>';
$date.= '<td>'.$staff['id'].'</td>';
$date.= '<td>'.$staff['name'].'</td>';
$date.= '<td>'.$staff['age'].'</td>';
$date.= '<td>'.$staff['sex'].'</td>';
$date.= '<td>'.$staff['email'].'</td>';
$date.= '<td>'.$staff['password'].'</td>';
}
echo "$date";
?>
</tbody>
</table>
<p>总计:
<?php echo $total; ?>
人</p>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号