表格问题(在表格的早期结束)

How*_*opa 3 html php forms

我在mysql数据库上通过php运行查询.使用我的结果集,我正在迭代下表:

        $resultString = '<table>';
        $resultString .= '<tr>';
        $resultString .= '<th>Index</th>';
        $resultString .= '<th>Title</th>';
        $resultString .= '<th>File</th>';
        $resultString .= '<th>Template File</th>';
        $resultString .= '<th>Pretty URL</th>';
        $resultString .= '<th>Parent</th>';
        $resultString .= '<th></th>';
        $resultString .= '</tr>';

        while($data = mysql_fetch_assoc($results)){
            $resultString .= '<form class="myForm">' ."\n";

            $resultString .= '<tr>' ."\n";

            $resultString .= '<input type="hidden" name="index" value="' . $data['index'] . '">' ."\n";
            $resultString .= '<input type="hidden" name="title" value="' . $data['title'] . '">' ."\n";
            $resultString .= '<input type="hidden" name="file_name" value="' . $data['file_name'] . '">' ."\n";
            $resultString .= '<input type="hidden" name="template_file" value="' . $data['template_file'] . '">' ."\n";
            $resultString .= '<input type="hidden" name="child_of" value="' . $data['child_of'] . '">' ."\n";
            $resultString .= '<input type="hidden" name="pretty_url" value="' . $data['pretty_url'] . '">' ."\n";

            $resultString .= '<td class="indexTd">' . $data['index'] . '</td>' ."\n";
            $resultString .= '<td>' . $data['title'] . '</td>' ."\n";
            $resultString .= '<td>' . $data['file_name'] . '</td>' ."\n";
            $resultString .= '<td>' . $data['template_file'] . '</td>' ."\n";
            $resultString .= '<td>' . $data['pretty_url'] . '</td>' ."\n";
            $resultString .= '<td>' . $this->get_parent_select_list($data['child_of'],$data['index']) . '</td>' ."\n";
            $resultString .= '<td class="buttonTd"><input type="button" class="deletePageButton" value="X" onclick="submit_form(this,\'deletePage\')"></td>' ."\n";

            $resultString .= '</tr>' ."\n";

            $resultString .= '</form>' ."\n";
        }

        $resultString .= '</table>';
Run Code Online (Sandbox Code Playgroud)

表格很棒,唯一的问题是我的表格根本不起作用...在FireBug中查看它我看到了这个:

替代文字

表单正在关闭,因为我的所有输入标签都可以填充它.我已经尝试将标签放在"<td>"而不是"<tr>"中无济于事....

想法?

Joh*_*han 11

当您在另一个标记中打开标记时,您打开的标记将在其父标记关闭时关闭.所以这:

<p><form></p>
<p></form></p>
Run Code Online (Sandbox Code Playgroud)

将(或应该)导致:

<p><form></form></p>
<p></p>
Run Code Online (Sandbox Code Playgroud)

您应该在桌子上方打开表格并将其关闭在底部,从而将整个表格封闭在表格中.

在tr,td,thead,tbody,toot或th标签之间放置非表标签是不好的做法,不符合w3c标准