-2
我想创建一个表我的TCPDF,其中的内容是从MySQL数据库插入:TCPDF如何创建循环内容的表格?
$html = '<table nobr="true">';
$pdf->writeHTML($html, true, false, true, false, '');
$pdo = $db->prepare("SELECT * FROM data WHERE id=?");
$pdo->execute(array($id));
while ($row = $pdo->fetch(PDO::FETCH_ASSOC)) {
$html = '<tr><td>'.$row['name'].'</td></tr>';
$pdf->writeHTML($html, true, false, true, false, '');
}
$html = '</table>';
$pdf->writeHTML($html, true, false, true, false, '');
,但我得到了很多的错误信息:
Notice: Undefined index: rows in ...
Warning: array_push() expects parameter 1 to be array, null given in...
Notice: Undefined variable: cellspacingx in...
Notice: Undefined variable: cellspacing in...
Notice: Undefined index: rows in...
它必须有东西用桌子做。但我不知何故需要创建一个表格,这不会被新页面打破。
UPDATE:
我现在测试的另一种解决方案:
$a = '<table nobr="true">';
$pdo = $db->prepare("SELECT * FROM data WHERE id=?");
$pdo->execute(array($id));
while ($row = $pdo->fetch(PDO::FETCH_ASSOC)) {
$b .= '<tr><td>'.$row['name'].'</td></tr>';
}
$c = '</table>';
$pdf->writeHTML($a.$b.$c, true, false, true, false, '');
但仍然有错误:
Notice: Undefined variable: b
([在问题中回答编辑并转换为社区wiki](http://meta.stackoverflow.com/questions/267434/what-is-the-woole-action-when-the-answer-to-a-问题 - 被添加到所述阙)) –