【问题标题】:PHP+TCPDF foreach faultPHP+TCPD foreach 故障
【发布时间】:2016-09-09 04:41:08
【问题描述】:

我是 PHP 新手。我的目标是使用 TCPDF 库将用户在表单字段中插入的数据传输到 PDF。在 Windows XP 上它工作正常,一切正常,但如果我尝试在 Windows 7 上生成 PDF,它会给我以下报告。

Notice: Undefined index: startcolumn in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19345
Notice: Undefined index: startx in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19346
Notice: Undefined index: startpage in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19349
Notice: Undefined index: startpage in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19352
Notice: Undefined index: in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19352
Notice: Undefined index: startpage in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19353
Notice: Undefined index: in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19353
Notice: Undefined index: startpage in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19385
Notice: Undefined index: startx in C:\xampp\htdocs\tcpdf\tcpdf.php on line 19605
TCPDF ERROR: Some data has already been output, can't send PDF file

这是有问题的代码:

foreach( $_POST['mat_tit'] as $key => $_POST['mat_tit'] ) {
    $mat_list_data = '
    <table cellpadding="1" cellspacing="0">
        <tr>
            <td width="100%">'.$_POST['mat_tit'].'</td>
        </tr>
    </table>
    <table cellpadding="2" cellspacing="2">
        <tr>
            <td width="13%">'.$mat_up[$key].'</td>
            <td width="5%">Kč</td>
            <td width="12%">'.$mat_q[$key].'</td>
            <td width="5%">'.$mat_ut[$key].'</td>
            <td width="5%">'.$mat_c[$key].'</td>
            <td width="13%">'.$mat_isum[$key].'</td>
            <td width="5%">Kč</td>
            <td width="6%">'.$mat_vv[$key].'</td>
            <td width="13%">'.$mat_vs[$key].'</td>
            <td width="5%">Kč</td>
            <td width="13%">'.$mat_itot[$key].'</td>
            <th width="5%">Kč</th>
        </tr>
    </table>';
}

// print $mat_list_data
$pdf->writeHTML($mat_list_data, true, true, false, false, '');

有没有人可以帮我解决这个问题?非常感谢大家

【问题讨论】:

  • 您只有一个答案还是只有一个问题?也许这只是关于 foreach 而不是关于 TCPDF,但请注意我主题的第一行 - 我是新人,这就是我问你的原因。

标签: php foreach tcpdf


【解决方案1】:

您需要删除代码中的双引号并在表格中使用单引号;

$mat_list_data = "
<table cellpadding='1' cellspacing='0'>
....
....        
....
";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-22
    • 2012-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多