-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.php
More file actions
79 lines (64 loc) · 1.78 KB
/
pdf.php
File metadata and controls
79 lines (64 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require('fpdf.php');
session_start();
$query = $_POST['query'];
class myPDFGenerator extends FPDF{
var $query;
function connectWithDB($sql){
$serverName = 'localhost';
$userName = 'root';
$passWord = '';
$db = 'COVID';
$conn = mysqli_connect($serverName, $userName, $passWord, $db);
$execSql = $sql;
return mysqli_query($conn, $sql); //return the result of executed query.
$conn->close();
}
function header(){
//set font Arial, Size 15
$this->Image('Pic.jpg',100,10,20,20, 'JPG');
$this->SetFont('Arial','I',18);
$this->Cell(20,20,'',0,0,'C');
$this->Ln();
$this->SetFont('Arial','I',18);
$this->SetTextColor(255, 0, 0);
$this->Cell(200,20,'Student Covid 19 Vaccine Documents',0,0,'C');
$this->Line(20,45,190,45);
$this->Ln();
$this->SetFont('Arial','B', 6.5);
$this->SetTextColor(17, 27, 43);
$this->SetRightMargin(100);
$result = $this->connectWithDB($_POST['query']);
while($columnInfo = mysqli_fetch_field($result)){
$this->Cell(22,10, $columnInfo->name, 1,0, 'C');
}
$this->Ln();
}
function footer(){
$this->SetY(-15);
$this->SetFont('Arial', 'B', 7.5);
$this->Cell(22,10,'Page No: '.$this->PageNo().'/{nb}',0,0,'C');
}
function __construct()
{
parent::__construct();
$query = $_POST['query'];
}
function viewTable(){
$result = $this->connectWithDB($_POST['query']);
$this->SetFont('Arial', 'I', 6.0);
while($rows = mysqli_fetch_row($result)){
for($i=0;$i<mysqli_num_fields($result);$i++){
$this->Cell(22,10, $rows[$i], 1,0, 'C');
}
$this->Ln();
}
}
}
$pdf = new myPDFGenerator();
$pdf->AliasNbPages();
$pdf->AddPage('P','A4',0);
$pdf->SetFont('Arial','', 16);
$pdf->viewTable();
$pdf->Output();
?>