<?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);
}
}
}
?>
Thanks Brian, I updated the code, I just remove redundant data so it will not be too long. Thanks again for taking another looked.
I want to print 50 plus pdf and save it to the designated folder with pdf name as Employee number coming from mysql database. Now the issue is only last data in the while loop is being converted to pdf, if i transfer the closing bracket of the first query to the last code after html, the pdf converted is only the first one. When I echo $Employee_Number = $row1[0] I get all the 50+ data. I already tried iterations such as for, but it becomes more complicated since it print out the exact number of pdf's but with no data being printed, Hoping somebody a help or hint on how to proceed. Thank you ahead.