【发布时间】:2019-11-20 09:39:25
【问题描述】:
好的,我有一个代码可以在同一个表单上显示图像
就像formid=7 有两个图像,当我在网页上运行相同的查询时它会显示两个图像。但是当我在 PDF (TCPD) 中应用相同时,它只显示一张图像,我不知道为什么
代码:
if (isset($_POST['submits'])){
require_once 'includes/practice.php';
$pdf->SetFont('times', '', 10);
$pdf->SetFont('aealarabiya', '', 12);
//$pdf->SetTopMargin(5);
//$pdf->AddPage('L','A4');
include('connect.php');
$emp_number=$_POST['emp_number'];
$formid=$_POST['formid'];
//$image='<span><div> <h2>Shop Images:</h2></div>';
//$getFiles = "SELECT * FROM inspection_files where formid=$formid";
$getFiles = $link->query("SELECT * FROM inspection_files WHERE formid=$formid");
if($getFiles->num_rows > 0){
while($row = $getFiles->fetch_assoc()) {
$imageURL = 'images/'.$row["file_name"];
$images='<img src="'.$imageURL.'" width="150" />';
}
} else {
echo '<p>No image(s) found...</p>';
}
我在 HTML 中的某个地方请求了 formid,例如 $_REQUEST['formid'];
【问题讨论】:
-
将
$images =更改为$images .=。它会在每一步中覆盖您的图像 -
如何将图像添加到 PDF?您正在遍历查询结果,但似乎没有对它们做任何事情。
-
@crazyloonybin 它不是一个完整的代码...添加到 PDF 是由为 pdf 定义的 writehtml
-
@ArmKh 肯定让我试着回来
-
正如@ArmKh 指出的那样,您在while 循环的每次迭代中都会覆盖图像。您可以执行他们的建议并每次都附加图像详细信息,也可以将
writeHTML()调用添加到 while 循环中。