This topic is locked
[SOLVED]

 Add/Edit Page > Before Record Added > QR Code

5/6/2016 7:50:27 PM
PHPRunner General questions
M
mmaner author
Sergey Kornilov admin 5/9/2016

$values is an array that stores values of individual fields. You need to use it the following way:

$values["FieldName"]


$values["https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1=";] simply doesn't make any sense.
You can not also use backticks (`) instead of double quotes (").

M
mmaner author 5/9/2016



$values is an array that stores values of individual fields. You need to use it the following way:

$values["FieldName"]


$values["https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1=";] simply doesn't make any sense.
You can not also use backticks (`) instead of double quotes (").


The idea is to use the Google QR Code Generator to create an link to the specific page where the data is recorded.
The following MySQL query works, I guess I am confused how to translate it to PHPRunner.

UPDATE `DBTable` SET `barcodevalue` = CONCAT("https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1=";,`id`)

UPDATE `DBTable` SET `barcodeimage` = CONCAT("https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1==",`id`)
Sergey Kornilov admin 5/9/2016

Is 'id' is your key column or just a regular field?

M
mmaner author 5/9/2016



Is 'id' is your key column or just a regular field?


It is the key column.

Sergey Kornilov admin 5/9/2016

The problem with key column that its value doesn't exist before record is physically created in the database. In BeforeAdd event the record in question doesn't exist yet.
What you can do is to run the same SQL code in AfterAdd event:

CustomQuery("UPDATE `DBTable` SET `barcodevalue` = CONCAT("https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1=",`id`)");

CustomQuery("UPDATE `DBTable` SET `barcodeimage` = CONCAT("https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1==",`id`)");
M
mmaner author 5/10/2016



The problem with key column that its value doesn't exist before record is physically created in the database. In BeforeAdd event the record in question doesn't exist yet.
What you can do is to run the same SQL code in AfterAdd event:

CustomQuery("UPDATE `DBTable` SET `barcodevalue` = CONCAT("https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1=",`id`)");

CustomQuery("UPDATE `DBTable` SET `barcodeimage` = CONCAT("https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://10.1.1.1/phprnrapp_view.php?editid1==",`id`)");



Makes sense, can't believe I didnt think about that. thanks

M
mmaner author 5/10/2016



Makes sense, can't believe I didnt think about that. thanks


I keep getting an error...

syntax error, unexpected 'https' (T_STRING) in line 1



I think its the forward slashes (//) in the URL being recognized as a comment. Is there any way around that?

M
mmaner author 5/10/2016