Adding QR code with MySQL data to Image

Here is a blank template ( certificate ).
certificate template

By using this template we will generate certificate for each student by using their data from MySQL student table. We will generate QR code by using student ID and add it to Certificate (Image).

Select one student from the list below and generate its certificate.

Generating certificates using student photo QR code & logo with data from MySQL table using PHP GD

Collecting details from MySQL table

Read and download the sample code on how to generate certificates for
all students using MySQL student table data.

In this scirpt we are collecting one record at a time, we will use PHP Data Object ( PDO ) to get data like this.
require "config-pdo.php"; // database connection 
$id=$_GET['id']; // receive the id value from selection
$sql="SELECT * FROM student where id=:id";
$count=$dbo->prepare($sql);
$count->bindParam(":id",$id,PDO::PARAM_INT,2);

if($count->execute()){
$row = $count->fetch(PDO::FETCH_OBJ);

	// Full code to create image with QR code. 

}

How to generate QR code as Image

We will be using google chart api to generate QR code. DEMO : Generate QR code by entering data
$QR=imagecreatefromstring(file_get_contents(
"https://chart.googleapis.com/chart?chs=100x100&cht=qr&chl="
.urlencode($row->id)));
In above code we are passing the student id ( $row->id ) and generating the QR code as image and storing in variable $QR.

Adding QR code to Image

We already discussed how the image with student mark ( data ) is added to the template.
Read and download the sample code on how to generate certificates for
all students using MySQL student table data.

Before generating the final image we will add the QR code to image at right top location, the position can be changed by adjusting the coordinates.
imagecopyresampled($img_source,$QR,475, 40,0,0,100,100,100,100);
imagejpeg($img_source);
imagedestroy($img_source);

Download the script

We strongly advise to first read the tutorial and watch the video on how to generate certificates for all students by taking data from MySQL table.
Read and download the sample code on how to generate certificates for
all students using MySQL student table data.

To above script, only the QR code image part is added and one certificate is created at a time by using the student id. Accordingly the PDO script is modified.

Use the same instructions given at above link to install the script and use the main file gd-certificate.php file to check the generated certificate for student id = 4.

Post your questions or suggestions here or at Youtube …

QR code in PDF documents, invoices

Every invoice will have one unique ID. This ID is used to link to other details like address of buyer, address of seller, invoice details , location details and other tracking codes. By using this unique ID, one QR code is generated and the same is embedded in the printed invoice or over the packing box.

This QR code can be scanned at every stage from packing to delivery point and status can be updated at the central database.
How QR code is embedded in Certificate ( PDF ) using MySQL table data

GD functions
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com











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