表和PHP的问题

Nat*_*pos 0 html php html-table

我正在使用此代码填充表:

<style type="text/css">
table, td
{
    border-color: #600;
    border-style: solid;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}

td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
    background-color: #FFC;
}
</style>

<table>
<tr>
<th>Files</th>
</tr>
<?php
foreach(new DirectoryIterator('/home/nathanpc/public_html') as $directoryItem) {
    if($directoryItem->isFile()) {
        printf('<td><tr><a href="/%1$s">%1$s</a></tr></td>', $directoryItem->getBasename());
    }
} ?>
</table>
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试它时,我得到的是桌子外面的价值,而且都是杂乱无章的.它位于服务器上:http://surl.x10.mx/list.php

Art*_*cto 5

应该是:

printf('<tr><td><a href="/%1$s">%1$s</a></td></tr>', $directoryItem->getBasename());
Run Code Online (Sandbox Code Playgroud)

tr表示"表行",这些应该封装tds,而不是相反.