好的,我一直在看这个代码,我无法弄清楚为什么它会添加重复的代码。表数据没有添加任何额外的td,所以我有点难过。这可能是因为某个地方遗漏了一个元素吗?我不认为我的PHP代码无论如何都会影响它。
<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta name="description" content="">
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/master.css">
</head>
<body>
<?php
//header("Content-type: application/vnd.ms-excel");
//header("Content-Disposition: attachment; filename=excel.xls");
include('queries.php');
$role = $_POST["role"];
$menu = $_POST["menu"];
$tests = getTestCases($role, $menu);
?>
<form action="testCaseToExcel.php" method="post">
<input type="submit" value="Download to Excel" />
</form>
<table border="1" style="width: 100%;">
<thead>
<tr>
<th>Role<th>
<th>Path<th>
<th>Link<th>
<th>Link Type<th>
</tr>
</thead>
<?php
foreach ($tests as $test) { ?>
<tr>
<td>
<?php echo $test->role;?>
</td>
<td>
<?php echo $test->path;?>
</td>
<td>
<?php echo $test->link_name;?>
</td>
<td>
<?php echo $test->link_type;?>
</td>
</tr>
<?php }
?>
</table>
<form action="testCaseToExcel.php" method="post">
<input type="submit" value="Download to Excel" />
</form>
</body>
</html>
答案 0 :(得分:1)
您未能关闭任何<th>
代码。应该是:
<tr>
<th>Role</th>
<th>Path</th>
<th>Link</th>
<th>Link Type</th>
</tr>
答案 1 :(得分:0)
好像你正在制作一个html语法错误
<tr>
<th>Role<th>
<th>Path<th>
<th>Link<th>
<th>Link Type<th>
</tr>
代码中的进行以下更改 我认为你应该使用标题标签的结束标签,看它可能会有帮助
<tr>
<th>Role</th>
<th>Path</th>
<th>Link</th>
<th>Link Type</th>
</tr>