Php mPDF生成多个PDF';使用动态HTML模板进行循环
我正在尝试使用接受报价id的动态html模板生成多个报价。当循环通过id时,生成第一个PDF,然后失败,出现以下错误 “PHP致命错误:在第22行的/home/eepherg/public_html/mobikote1.2/followups.PHP中调用null上的成员函数fetch()” 似乎include就是问题所在,如果我将其从循环中删除,则会创建多个空白PDF。如何包含多次输出缓冲的动态模板。。。这是我的代码,任何帮助都将不胜感激Php mPDF生成多个PDF';使用动态HTML模板进行循环,php,mpdf,output-buffering,Php,Mpdf,Output Buffering,我正在尝试使用接受报价id的动态html模板生成多个报价。当循环通过id时,生成第一个PDF,然后失败,出现以下错误 “PHP致命错误:在第22行的/home/eepherg/public_html/mobikote1.2/followups.PHP中调用null上的成员函数fetch()” 似乎include就是问题所在,如果我将其从循环中删除,则会创建多个空白PDF。如何包含多次输出缓冲的动态模板。。。这是我的代码,任何帮助都将不胜感激 <?php include($_SERVER[
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/mpdf/mpdf.php");
require ("/home/eepherg/cnct_mobiquote.php");
try {
$sql = "SELECT
a.headersid,
c.email,
a.ref,
a.description,
c.clientname,
d.doc_template
FROM `headers` a
JOIN `users` b ON a.userid = b.userid
JOIN `clients` c ON a.clientid = c.clientid
JOIN companies d ON a.companyid = d.companyid
WHERE a.follow_up_1 = CURRENT_DATE AND a.status = 2 AND a.active = 1"; //only incomplete and emailed quotes
$stmt = $conn->prepare($sql);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$quoteid = $row[0];
$email = $row[1];
$quote_ref = $row[2];
$description = $row[3];
$client = $row[3];
$quote_template = $row[5];
//-- generate the .pdf
//set the path for the temp pdf
$savedtemppdf = $_SERVER['DOCUMENT_ROOT'] . "/mobiquote1.2/temp_pdf/".$quote_ref.".pdf";
$mpdf=new mPDF('c','A4','','',20,15,30,25,10,10);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->SetHTMLFooter('');
ob_start( );
include($_SERVER['DOCUMENT_ROOT'] . "/mobiquote1.2/templates/".$quote_template.".php?id=".$quoteid);
$output = ob_get_clean( );
ob_end_clean();
$mpdf->WriteHTML($output);
$mpdf->Output($savedtemppdf,'F');
//email the quote with attachment
}
}
catch(PDOException $e){
echo 'Error: ' . "<br />" . $sql . "<br />" . $e->getMessage() . "<br />";
}
//close the connection
$stmt = null;
$conn = null;
?>
您有一些sql
错误-请先调试。@freeek,谢谢您的回复。我已经按照上面的SQL语句在MYSQL中运行,没有错误。问题似乎在于循环中模板文件的多个包含。我不知道如何在维护动态模板功能的同时做到这一点。有什么想法吗?你有一些sql
错误-先调试一下。@freeek,谢谢你的回复。我已经按照上面的SQL语句在MYSQL中运行,没有错误。问题似乎在于循环中模板文件的多个包含。我不知道如何在维护动态模板功能的同时做到这一点。有什么想法吗?