-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_pdf.php
More file actions
48 lines (41 loc) · 1.45 KB
/
Copy pathgenerate_pdf.php
File metadata and controls
48 lines (41 loc) · 1.45 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
<?php
require('fpdf.php'); // FPDF Library Include
include 'db_connection.php'; // Database Connection
// PDF Class Banaye
class PDF extends FPDF {
function Header() {
$this->SetFont('Arial', 'B', 14);
$this->Cell(190, 10, 'Issued Books Report', 0, 1, 'C');
$this->Ln(5);
}
function Footer() {
$this->SetY(-15);
$this->SetFont('Arial', 'I', 10);
$this->Cell(0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C');
}
}
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(40, 10, 'Transaction ID', 1);
$pdf->Cell(60, 10, 'Book Title', 1);
$pdf->Cell(40, 10, 'Student Name', 1);
$pdf->Cell(40, 10, 'Issue Date', 1);
$pdf->Ln();
// Database Se Issued Books Fetch Karo
$query = "SELECT Transactions.transaction_id, Books.title, Students.name AS student_name, Transactions.issue_date
FROM Transactions
JOIN Books ON Transactions.book_id = Books.book_id
JOIN Students ON Transactions.student_id = Students.student_id
WHERE Transactions.status = 'Issued'";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(40, 10, $row['transaction_id'], 1);
$pdf->Cell(60, 10, $row['title'], 1);
$pdf->Cell(40, 10, $row['student_name'], 1);
$pdf->Cell(40, 10, $row['issue_date'], 1);
$pdf->Ln();
}
$pdf->Output('D', 'Issued_Books_Report.pdf'); // PDF Download Karne Ke Liye
?>