Hi,
Good day!
I have a query to display data from my database.
Here is my code:
$query3 = "SELECT employee_no, arabic_name, fullname, nationality, join_date, passport_no, passport_end_date, res_no, res_end_date, company_work, company_sponsor
FROM tbl_employee_informations WHERE res_end_date = '$date_visa' ORDER BY res_end_date";
$res = $conn->query($query3);
$cnt = $res->num_rows;
<p>
echo"<a href=\"expiring_visa_pdf.php\" target=\"_Blank\" style='float:left;margin:auto auto 10px auto;font-weight:bold;text-decoration:none; color:#8d735a;'>Generate PDF<a/>";
echo "<p style='float:left;margin:auto auto auto 350px;font-weight:bold; color:#8d735a;'>Total: $cnt </p>";
echo "<div id='report_one'>";
echo "<table style='border-radius:3px; border: 1px solid #a6a6a4;'>";
echo "<tr style='text-align:center;font-weight:bold; background-color:#FFF;'>";
echo "<th class='report_table'>EMPLOYEE NO.</th>";
echo "<th class='report_table'>ARABIC NAME</th>";
echo "<th class='report_table'>ENGLISH NAME</th>";
echo "<th class='report_table'>NATIONALITY</th>";
//echo "<th class='report_table'>JOIN DATE</td>";
echo "<th class='report_table'>PASSPORT NO.</th>";
//echo "<th class='report_table'>PASSPORT END DATE</th>";
echo "<th class='report_table'>RESIDENCY ID</th>";
echo "<th class='report_table'>RESIDENCY END DATE</th>";
echo "<th class='report_table'>COMPANY WORK</th>";
echo "<th class='report_table'>COMPANY SPONSOR</th>";
echo "</tr>";
while($row = $res->fetch_assoc())
{
$employee_no = $row['employee_no'];
$fullname = $row['fullname'];
$fullname = utf8_encode($fullname);
$arabic_name = $row['arabic_name'];
$nationality = $row['nationality'];
$join_date = $row['join_date'];
$join_date = date('d-m-Y',strtotime($join_date));
$passport_no = $row['passport_no'];
$passport_end_date = $row['passport_end_date'];
$passport_end_date = date('d-m-Y',strtotime($passport_end_date));
$res_no = $row['res_no'];
$res_end_date = $row['res_end_date'];
$res_end_date = date('d-m-Y',strtotime($res_end_date));
$company_work = $row['company_work'];
$company_sponsor = $row['company_sponsor'];
echo "<tr>";
echo "<td class='report_table'>$employee_no</td>";
echo "<td class='report_table' dir='RTL'>$arabic_name</td>";
echo "<td class='report_table'>$fullname</td>";
echo "<td class='report_table'>$nationality</td>";
//echo "<td class='report_table'>$join_date</td>";
echo "<td class='report_table'>$passport_no</td>";
//echo "<td class='report_table'>$passport_end_date</td>";
echo "<td class='report_table'>$res_no</td>";
echo "<td class='report_table'>$res_end_date</td>";
echo "<td class='report_table'>$company_work</td>";
echo "<td class='report_table'>$company_sponsor</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
Now, I need to convert this table form html to pdf once I click the Generate PDF.
I don’t know how to do that.
I started by this:
<?php
require('fpdf/fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('images/logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Expiring Visa');
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
//for($i=1;$i<=40;$i++)
// $pdf->Cell(0,10,'Printing line number '.$i,0,1);
//$pdf->Cell();
$pdf->Output();
?>
but in this code I can only show the logo and title
I hope someone can help me on this matter.
Thank you.