DOMPDF,给我带来了一个错误

use*_*204 2 html php mysql dompdf

这是我在PdfHtml类中的代码:

public function createTable($result){

    $html = "<html>
                    <body>
                        <table>
                            <th>
                                <td>Descripción</td>
                                <td>Artículo</td>
                                <td>Precio</td>
                            </th>
                        ";
    while($row = mysql_fetch_array($result)){
        $html .= "<tr>";
        $html .= "<td>".$row["producto"]."</td>";
        $html .= "<td>".$row["idProducto"]."</td>";
        $html .= "<td>".$row["precio"]."</td>";
        $html .= "</tr>";
    }

    $html .= "</table>
                </body>
                    </html>";

    return $html;
}
</i>
Run Code Online (Sandbox Code Playgroud)

我执行以下操作:

$pdfHtml = new PdfHTML();
$result = $pdfHtml->getProductosPorMarca($idMarca);
$html = $pdfHtml->createTable($result);

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->output();
Run Code Online (Sandbox Code Playgroud)

抛出这个:

Catchable fatal error: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, null given, called in /opt/lampp/htdocs/ONLINE/dompdf0.6/include/table_frame_decorator.cls.php on line 304 and defined in /opt/lampp/htdocs/ONLINE/dompdf0.6/include/frame.cls.php on line 726
Run Code Online (Sandbox Code Playgroud)

请帮帮我,我没发现我的错误在哪里!谢谢!!

Bri*_*anS 7

您的HTML是问题的根源.你已经在TH元素中嵌套了一堆TD元素,但这是无效的.容器应该仍然是TR元素; 那么单个细胞就是TH元素.如果你想要一个跨页面重复的表头,你可以将标题行嵌套在THEAD元素中,并将表格的主体嵌套在TBODY元素中.