Dompdf while loop-仅最后一条记录转换为pdf .第1节{ 利润上限:110像素; 左边距:108px; 边缘底部:5px; } 您应该包含一个更完整的代码示例(例如while循环在做什么?),这看起来像是PHP的结构性问题,而不是dom
Dompdf while loop-仅最后一条记录转换为pdfDompdf while loop-仅最后一条记录转换为pdf .第1节{ 利润上限:110像素; 左边距:108px; 边缘底部:5px; } 您应该包含一个更完整的代码示例(例如while循环在做什么?),这看起来像是PHP的结构性问题,而不是dom,php,dompdf,Php,Dompdf,Dompdf while loop-仅最后一条记录转换为pdf .第1节{ 利润上限:110像素; 左边距:108px; 边缘底部:5px; } 您应该包含一个更完整的代码示例(例如while循环在做什么?),这看起来像是PHP的结构性问题,而不是dompdf问题。你应该花更多的时间检查你的逻辑,请,请,请尝试格式化你的代码。它不仅有助于我们审查您的问题,还可以帮助您发现逻辑中的问题。你的情况有点乱。我做了我能做的,但是有一些基本的结构问题(例如,在外面打开HTML,在里面关闭)。 <?
.第1节{
利润上限:110像素;
左边距:108px;
边缘底部:5px;
}
您应该包含一个更完整的代码示例(例如while循环在做什么?),这看起来像是PHP的结构性问题,而不是dompdf问题。你应该花更多的时间检查你的逻辑,请,请,请尝试格式化你的代码。它不仅有助于我们审查您的问题,还可以帮助您发现逻辑中的问题。你的情况有点乱。我做了我能做的,但是有一些基本的结构问题(例如,在外面打开HTML,在里面关闭)。
<?php require"../db_connection1.php";?>
<?php require"../db_connection4.php";?>
<?php require"../db_connection5.php";?>
<?php
require_once('../dompdf/autoload.inc.php') ;
use Dompdf\Dompdf ;
ob_start() ;
if (isset($_POST["submit"])) {
$payroll_date = mysqli_real_escape_string($connection5, $_POST["payroll_date"]) ;
}
$query = "SELECT * FROM ".$payroll_date." ";
$result = mysqli_query($connection5, $query);
while ($row1 = mysqli_fetch_array($result)) {
$Employee_Number = $row1[0] ;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="../bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.SECTION-1 {
margin-top:110px ;
margin-left: 108px ;
margin-bottom: 5px ;
}
</style>
</head>
<body>
<form action = "#" method ="POST">
<div class ="SECTION-1" >
<?php
$query_hr_data = "SELECT * FROM applicants_final WHERE employee_number = '{$Employee_Number}' ";
$result = mysqli_query($connection4, $query_hr_data );
while ($row5 = mysqli_fetch_array($result)) {
$cost_center = $row5['cost_center'] ;
$position = $row5['position'] ;
$query = "SELECT * FROM ".$payroll_date." WHERE EE_NUMBER = '{$Employee_Number}' ";
$result = mysqli_query($connection5, $query);
while ($row1 = mysqli_fetch_array($result)) {
$EE_NUMBER = $row1['EE_NUMBER'] ;
$EE_NAME = $row1['EE_NAME'] ;
$query2 = "SELECT * FROM ".$payroll_date." WHERE EE_NUMBER = '{$Employee_Number}' ";
$result = mysqli_query($connection1, $query);
while ($row2 = mysqli_fetch_array($result)) {
$LATES_UNDERTIME_HRS = $row2['LATES_UNDERTIME'] ;
$ABSENCES_HRS = $row2['ABSENCES'] ;
echo "<table id ='heading'>" ;
echo"<tr>" ;
echo"<th id ='heading-2-1'>EE Name </th>" ;
echo"<td id ='heading-2'>" .$row1['EE_NAME']." </br> </td>" ;
echo"<th id ='heading-2-1'>Philhealth # </th>" ;
echo"<td id ='heading-2'>" .$philhealth_number." </br> </td>" ;
echo"</tr>" ;
echo"<tr>" ;
echo"<th id ='heading-2-1'>Basic_Salary </th>" ;
echo"<td id ='heading-2'>" .number_format($basic_salary,2). "</br> </td>" ;
echo"<th id ='heading-2-1'> Allowances </th>" ;
echo"<td id ='heading-2'>" .number_format($deminimis_benefits,2)."</br> </td>" ;
echo"</tr>" ;
echo "</table>" ;
echo "<table id='design-8'>" ;
echo"<tr>" ;
echo"<th>Lates_Undertime ( minutes ) </th>" ;
echo"<td>" .$LATES_UNDERTIME_HRS. "</br> </td>" ;
echo"<td>" .$LATES_UNDERTIME." </br> </td>" ;
echo"</tr>" ;
echo"<tr>" ;
echo"<th>Absences </th>" ;
echo"<td>" .$ABSENCES_HRS." </br> </td>" ;
echo"<td>" .$ABSENCES." </br> </td>" ;
echo"</tr>" ;
echo "</table>" ;
echo "<div id='design-2'> *** Payslip Confidential *** </div>" ;
?>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</body>
</html>
<?php
$html = ob_get_clean();
$dompdf = new Dompdf();
$dompdf->load_html($html);
$dompdf->setPaper(array(0, 0, 612, 1100), 'portrait');
$dompdf->render();
$pdf = $dompdf->output();
$file_location = "C:/wamp/www/dbs-program/payroll-program/version-3.4/pdfReports/".$Employee_Number.".pdf" ;
file_put_contents($file_location, $pdf);
}
}
}
?>