2014-01-29 178 views
1

我是一個PHP新手。我的目標是使用TCPDF庫將用戶在表單字段中插入的數據轉換爲PDF。在Windows XP上它工作正常,一切正常,但如果我嘗試在Windows 7上生成PDF,它會給我下面的報告。PHP + TCPDF foreach故障

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, ''); 

有沒有人,誰可以幫我解決這個問題呢?謝謝很多人

+1

你只有一個答案或只有問題?也許這只是關於foreach,而不是關於TCPDF,但注意我的主題的第一行 - 我是一個更新的,這是理由,爲什麼我問你。 – user3120196

回答

0

您需要刪除代碼中的雙引號,並在表中使用單引號;

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