-1

好的,我一直在看这段代码,但我不明白为什么它会添加重复的 th。表格数据没有添加任何额外的 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>
4

2 回答 2

1

您未能关闭任何<th>标签。应该:

<tr>
    <th>Role</th>
    <th>Path</th>
    <th>Link</th>
    <th>Link Type</th>
</tr>
于 2012-10-06T15:40:17.573 回答
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>
于 2012-10-06T16:35:04.980 回答