<?php
//这段代码对未通过会员认证的人进行了跳转登录页面的处理
if($_COOKIE['userRight']!= 'normalRight'){
header('location:loginPage.php');
exit();
}
require_once('dataBase.php');//create the connection to database
$userName=$_COOKIE['userName'];
$sql="SELECT * FROM result_table WHERE userName='$userName' ";
$result=$conn->query($sql);//we get all record in this step
$recordNumber=$result->num_rows;//we get the total number of the records'rows which we need
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>历史测评结果展示页面</title>
<style>
div{
width: 500px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 20px;
}
table{
font-size: 30px;
text-align: center;
}
td{
white-space: nowrap;
padding: 10px;
width: 30px;
}
input{
font-size: 18px;
}
</style>
</head>
<body>
<div>
<table >
<tr>
<td >测评人</td>
<td>测评时间</td>
<td>测评序列</td>
<td>查看结果</td>
</tr>
<?php
if($recordNumber>0){
while($row=$result->fetch_assoc()){
$userName=$row['userName'];
$testDate=$row['testDate'];
$testTime=$row['testTime']; //必须要转换一下,因为直接放到下面的 html代码块中 就会出现问题
$testTime%2?$backGroundColor='F0F8FF':$backGroundColor='transparent';
echo <<<EOF
<form action='resultHistory.php' method='post'>
<tr>
<td bgcolor=$backGroundColor ><input type='text' value='$userName' readonly='readonly' >
<td bgcolor=$backGroundColor><input type='text' value='$testDate' readonly='readonly'>
<td bgcolor=$backGroundColor><input type='text' value='$testTime' readonly='readonly'>
<td bgcolor=$backGroundColor> <input type='submit' value='查看记录'>
</tr>
</form>
EOF;
}
}else{
echo '暂时没有进行任何测试';
}
$conn->close();
?>
</table>
</div>
</body>
</html>