本文介绍了如何用PHP编写PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它不会在pdf中显示ite1值.为什么?您能改正我的错误吗?
It doesn't display ite1 value in the pdf. Why? Could you please, correct my mistake?
<?php
set_include_path($_SERVER['DOCUMENT_ROOT'] .'/mpdf/');
require('mpdf.php');
$n = 0;
$mpdf=new mPDF();
require_once('../../includes/common.php');
$result = mysql_query("SELECT * from sgc where year = '2010'") or die(mysql_error());
$row=mysql_fetch_array($result);
$nric=$row['nric'];
$row=mysql_fetch_array($result);
$meta_ite=$row['meta_ite'];
$mpdf->WriteHTML('<p>Hello World</p>');
$html1 = '<table>
<tr>
<td width="388">Module Description</td>
<td width="111"><div align="center">Grade</div></td>
<td width="92"><div align="center">Earned</div></td>
<td width="96"><div align="center">Authority</div></td>
<td width="74"><div align="center">Series</div></td>
</tr>';
$unser = $meta_ite;
$unser = unserialize($unser);
$count = count($unser);
for($j=0;$j<$count;$j++)
{
$ite1 = $unser[$i][0];
//print_r ($unser[$i][0]."--".$unser[$i][1]."--".$unser[$i][2]);
$html1 .= '<tr><td width="388">'.$nric.'</td>
<td width="111">'.$count.'</td>
<td width="92"><div align="center">'.$ite1.'</div></td>
<td width="96">ITE</td>
<td width="74">2010</td>
</tr>';
}
$html1 .= '</table>';
$mpdf->WriteHTML($html1);
$mpdf->Output('filename.pdf','D');
?>
推荐答案
首先,您要包括 mpdf 文件
first you include your mpdf file
require_once('./mpdf/mpdf.php');
还打开调试功能以查看错误.
also open debug functionality to see the error.
$mpdf->debug = true;
注意:请确保您具有服务器上以下文件夹的完整权限( 777 或 755 ):
Note: ensure that you have complete permission (777 or 755) for the following folders on server:
这篇关于如何用PHP编写PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!