psubbiah93@gmail.com

Wednesday, 18 November 2015

FPDF PDF Generation from MySQL using PHP


<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
$result = $db_handle->runQuery("SELECT * FROM toy");
$header = $db_handle->runQuery("SELECT `COLUMN_NAME` 
FROM `INFORMATION_SCHEMA`.`COLUMNS` 
WHERE `TABLE_SCHEMA`='blog_samples' 
    AND `TABLE_NAME`='toy'");

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

Download

Unknown Web Developer

Hello! I am Subbiah P and this is my web technologies blog. My specialities are PHP, Asp.net, jQuery, and CMS web application development. I do accept paid work. Write to me to start working on your dream project . I am Working as Web developer in Peace Soft Technologies

No comments:

Post a Comment