QRC in admin

By Toledoh - January 20, 2016

Hey guys.

How would I go about creating a QR Code in the admin.  ie.  I want to be able to create a record in a multi record section, and have a QR Code created for that record and displayed in the admin for the administrator to print out and use.

It can be random or based on the num of the record etc - but has to be unique.

Cheers,

Tim (toledoh.com.au)

Hey Tim, 

The simplest way to implement this feature is to create a separator and add custom HTML and PHP that displays a QR Code. The QR code gets the num of the record from the URL and uses that variable to create a unique ID. This QR code will appear after the first time they save the record.

Here is the code I added to the separator: 

<?php
if(@$_REQUEST['num']){
   echo qrCode(array(
      'type' => 'text',
      'text' => 'Hello world! ' . @$_REQUEST['num'],
    ));
   }
?>

I've attached a screenshot that shows how I implemented this code into the separator. 

The user would be able to print this by right clicking on the QR code and clicking 'open in new tab'. From here they could print the code without the other page content. 

Let me know if you have any questions. 

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

seperator example.png 118K

Hi Tim,

I thought I'd post the solution we used to resolve the issue to this forum thread:

<?php
if(@$_REQUEST['num']){
$record = mysql_get('blog', $_REQUEST['num']);    
echo qrCode(array(
      'type' => 'text',
      'text' => 'Hello world! ' . @$record ['title'],
    ));
   }
?>

So the code above was added to the separator HTML field. It will retrieve the current record if it exists, and allow you to access any variables from the record. You'll need to update the variable blog with the section you're currently editing. 

Just a note, this will load the data from the previous save of the record. So in this example if you made any changes to the title, they won't appear in the QR code until you reload the record.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com