1、概述
2、源代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>学生名单</title>
</head>
<body>
<?php include "data.php"; ?>
<table>
<thead>
<tr class="trbgchead">
<td>序号</td><td>学号</td><td>姓名</td>
</tr>
</thead>
<tbody>
<?php foreach ($allStudents as $k=>$v){?>
<?php if ($k%2!=0) {?>
<tr class="trbgc">
<?php }else{ ?>
<tr class="trbgc2">
<?php } ?>
<td><?php echo $k+1 ?></td>
<td><?php echo $v["sno"]; ?></td>
<td><?php echo $v["name"]; ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
</tfoot>
</table>
<style>
.trbgchead{
background-color: red;
}
.trbgc{
background-color: #eeeeee;
}
.trbgc2{
color: red;
}
</style>
</body>
</html>
3、源代码截图
4、运行结果截图
|