Display single record in a PDF page using variable from Query string

We can generate PDF page by taking data from the query string. This way we will pass variables to our script and using that we will generate our PDF page.

Generating PDF document using record from MySQL database with unique id in PHP using FPDF class


We will create a page to show mark obtained by each student by using a single PHP script. Our PHP script will receive student ID from query sting and generate the mark sheet of the student by taking data from the table.

Displaying list of students in a pdf document.

We will be using one similar student list and then on clicking on the name column of the record we will display the Mark sheet of the student. The link we will click will pass the student number or ID to our script. ( Details on adding QR code is explained below )
IDNameWith QR code
2 Max Ruin Max Ruin
3 Arnold Arnold
4 Krish Star Krish Star
5 John Mike John Mike
6 Alex John Alex John
7 My John Rob My John Rob
8 Asruid Asruid
9 Tes Qry Tes Qry
10 Big John Big John
PDF Mark sheet
// connection to database
require "config.php";
$pdf = new FPDF(); 
//collect student id from URL 
$q="select id,name,class,social,science,math,
(social + science + math) AS total from student3 where id=:id";

$row = $count->fetch(PDO::FETCH_OBJ);
/// adding QR code ////

// First header column 
$pdf->Cell(30,10,'MARK SHEET',0,0,'L',false);









Download Script

Inside the zip file you can open index1.php file to list all students in PDF , click the mark column to display the mark sheet of individual student ( index-pdf-mark.php is included inside the zip file.)

Check the readme.txt file for more detail.

Adding QR code to PDF document.

We can generate QR code by using the student id and the same can be inserted to the generated PDF document.
We will generate one QR code image by using Google chart API and same image we will insert to our document.
Here is the code to create the image ( QR code ) and add the same to our document.

How QR code is embedded in Certificate ( image ) using MySQL table data

MultiCell Cell()
Adding Image to PDF File
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Post your comments , suggestion , error , requirements etc here

    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer