Skip to content

Instantly share code, notes, and snippets.

@itswadesh
Created March 27, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itswadesh/cdaa68c247f34842b8799f261f67f859 to your computer and use it in GitHub Desktop.
Save itswadesh/cdaa68c247f34842b8799f261f67f859 to your computer and use it in GitHub Desktop.
<?php
include('config.php');
include('database.php');
$email = TO;
if(isset($_POST['email'])) $email = $_POST['email'];
$database = new Database();
$result = $database->runQuery("SELECT name,author FROM books");
$header = $database->runQuery("SELECT UCASE(`COLUMN_NAME`)
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='demos'
AND `TABLE_NAME`='books'
and `COLUMN_NAME` in ('name','author')");
require('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
foreach($header as $heading) {
foreach($heading as $column_heading)
$pdf->Cell(95,12,$column_heading,1);
}
foreach($result as $row) {
$pdf->Ln();
foreach($row as $column)
$pdf->Cell(95,12,$column,1);
}
$pdf->Output(ATTACHED_FILENAME,'F');
require('sendgrid.php');
$result = sendmail($email);
echo $result;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment