我正在尝试将 a 放入标签内,如下例所示,但表格显示在 tableWrapper div 之外,tableWrapper div 正确显示我想要但表格在它外面,我不明白是什么我做错了,有人可以帮忙吗? :
//the buttons
$html .= '<p><form method="post" action = "DBTest.php" >
<input type="submit" name="create" value="Create">
<input type="submit" name="save" value="Save">
<input type="submit" name="reset" value="Reset">
</form></p>';
//start table
$html.= '<div id = "tableWrapper"><table>';
foreach($rows as $row)
{
$id= $row['id'];
$title = $row['title'];
$year = $row['YEAR'];
//put everything on a table
$html.= "<tr><td>" . $row['id'] . "</td><td>" . $row['title'] . "</td><td>" . $row['year'] . "</td><td>";
}
$html.= '</table></div>';
//the main body
$alpha['main'] = <<<EOD
{$html}
EOD;
这是我的 tablWrapper div:
#tableWrapper{
clear:both;
width: 350px;
height: 350px;
}
这是我的表格 CSS:
table {margin-bottom:1.4em;}
th {font-weight:bold;background:black;color:white;}
th,td,caption {padding:4px 10px 4px 5px;}
tbody tr:nth-child(even) td {background:#A1912A11;}
tbody tr:hover td {background:#9E9E80;}
提前致谢
最佳答案
错别字:
$html.= "<tr><td>" [...snip...] . "</td><td>";
^^^^
你永远不会关闭你的 <tr>
标签,并以新的未终止 <td>
结束该行.所以你最终得到了
<div><table>
<tr><td>...</td><td>..</td><td>
<tr><td>...</td><td>..</td><td>
etc...
关于php - 无法将 <table> 标签放入 div 标签内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19931946/