This topic is locked
[SOLVED]

  echo field value in PHP Snippet

6/6/2012 6:28:56 PM
PHPRunner General questions
M
matthew999 author

How can I use the "PHP Snippet" feature to ECHO the value of a MySQL field?
My field is named: filename
When I use the code below, I get the error at the bottom of this post

[indent]echo $data["filename"];[/indent]

C
cgphp 6/6/2012

To get access to the field value in a PHP snippet, you have to run a query. Please, explain what you want to do and we'll help you to find an alternative way to do it.

M
matthew999 author 6/6/2012



To get access to the field value in a PHP snippet, you have to run a query. Please, explain what you want to do and we'll help you to find an alternative way to do it.


I have small PNG images (75x75 pixels) on my web server. Each PNG image has a file name that is the same as the value in the "filename" field. I'm trying to display them on the "list" screen. That way, the user can see the metadata about the image and a little thumbnail too. I want to write a PHP code snippet that renders this code:

echo '<img src="' . $filename . '.png">';
In this case, the first item on the list would would allow this code to call in the first PNG file to the interface, the second item on the list would call in the 2nd PNG file to the interface, etc.
My table looks like this:

Table Name:

img_tbl
Field Name:

filename
Values in the table:

filename:A

filename:B

filename:C
PNG files on my server:

A.png

B.png

C.png
Desired LIST page

HEADER: <blank> tab filename

ROW 1: <edit record button> <edit in line button> <preview button> <image of A.png> tab A

ROW 2: <edit record button> <edit in line button> <preview button> <image of B.png> tab B

ROW 3: <edit record button> <edit in line button> <preview button> <image of C.png> tab C
I thought it was possible to use whatever query PHPRunner used to create the list. PHPRunner is somehow doing that to call in the field values row by row. My understanding was there was a way to tap into that.
In any event, that's what I'm trying to do. Basically, using field data in a PHP code snippet to generate links to thumbnail images that I will insert, one each, on each row of the LIST page.
Thanks for any help you can provide.
Matt

Admin 6/7/2012

Instead of code snippet set 'View as' type of one of fields to 'Custom'. This way you can access any field value of any record.
Read the following article for more info (View as: Custom) section:

http://xlinesoft.com/blog/2011/04/28/taming-the-beast-events-buttons-and-code-snippets/

M
matthew999 author 6/7/2012



Instead of code snippet set 'View as' type of one of fields to 'Custom'. This way you can access any field value of any record.
Read the following article for more info (View as: Custom) section:

http://xlinesoft.com/blog/2011/04/28/taming-the-beast-events-buttons-and-code-snippets/


Yes... that worked! Many thanks!