简体   繁体   中英

How to export PHP/MYSQL data to PDF?

I have created a Student Information Form and it is connected to a MYSQL database and I want to export all the submitted data from MYSQL DB to PDF ?

How to do that ?

You should make use of PDF creator libraries like: FPDF , TCPDF, EzPDF

All three are easy to learn in the order I've put. The documentation of FPDF and EzPDF are very neat and clean. But TCPDF Documentation is not that readable.

Checkout this site: http://www.tcpdf.org/ . It also allows to output document created on the fly easily into a browser.

Also there is a good example of doing this: here is the link: https://www.phpflow.com/php/generate-pdf-file-mysql-database-using-php/

Hope this answer is helpful to you...

<?php
require('fpdf/fpdf.php'); 
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);      
foreach($result as $row) {
    $pdf->SetFont('Arial','',12);   
    $pdf->Ln();
    foreach($row as $column)
        $pdf->Cell(90,12,$column,1);
}
$pdf->Output();
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM