2012-10-06 57 views
-1

好的,我一直在看這個代碼,我不知道爲什麼它添加重複的th。表格中的數據沒有添加任何額外的td,所以我有點難堪。這可能是由於在某處丟失了一個元素?我不認爲我的PHP代碼無論如何都在影響它。添加額外的HTML表格

<!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

你沒有關閉任何你個標籤像不 ... – Onheiron

+0

看到正確關閉標籤它只是科幻ne:http://jsfiddle.net/aHRtE/1/ – Onheiron

回答

1

您未能關閉您的任何<th>標籤。應該是:

<tr> 
    <th>Role</th> 
    <th>Path</th> 
    <th>Link</th> 
    <th>Link Type</th> 
</tr> 
+0

我討厭當我做一些愚蠢的事情。 – jrock2004

+0

@ jrock2004:一個體面的IDE會在它們發生之前解決這些問題。 –

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>