This topic is locked
[SOLVED]

 wrong picture if rows less than 3

9/24/2014 4:16:54 PM
PHPRunner General questions
S
snuffi01 author

I hav eadded som code under custom (view as) on an listpage.

I want to display an picture instead of an value.

Problem is that if the list page only contain as example 2 rows the displayed picture

isnt the on eit should be (example, if list page contain 2 rows it display picture called ledorange.png)
Heres the code:
if ($value=="0")

$value="<img src=\"images/rd_dot.gif\">";
elseif ($value=="1")

$value="<img src=\"images/green-circle.png\">";
else

$value="<img src=\"images/ledorange.png\">";
I'm using PHPRunner 8.0
/ Kristian

Sergey Kornilov admin 9/24/2014

If you use 'View as' Custom variable $value contains the value of that field. It doesn't contain the number of records on the List page.

S
snuffi01 author 9/25/2014

HI,
My problem is when there is 2 rows with as example the value 1 in the both rows it should show picture green-circle.png

But it shows ledorange.png for both rows.

If list page contains 3 rows and more every picture is the right one....

A
Anapolis 9/25/2014



HI,
My problem is when there is 2 rows with as example the value 1 in the both rows it should show picture green-circle.png

But it shows ledorange.png for both rows.

If list page contains 3 rows and more every picture is the right one....


Your code should be using the name of the actual field that would show the value 1 or 2 or 3, etc.
Whatever field you have put the Custom Code into "View As" on the List page has to be specifically identified by name and that particular record value retrieved to be evaluated in your Custom Code.
For instance, if the field in each of your records was named "count" where the 0, 1, 2, 3 .... would be displayed then your code should look something like this ---



if ($data["count"]=='0'){

$value="<img src=\"images/red_ball.gif\">";

}

if ($data["count"]=='1'){

$value="<img src=\"images/greensquare.png\">";

}

if ($data["count"] >'1')

$value="<img src=\"images/ledorange.png\">";


So, if the field where you get the "value" from is called "qty" for Quantity of items
Then you should make your "View As" custom code in the "qty" field read --



if ($data["qty"]=='0'){

$value="<img src=\"images/red_ball.gif\">";

}

if ($data["qty"]=='1'){

$value="<img src=\"images/greensquare.png\">";

}

if ($data["qty"] >'1')

$value="<img src=\"images/ledorange.png\">";
A
Anapolis 9/25/2014



Your code should be using the name of the actual field that would show the value 1 or 2 or 3, etc.
Whatever field you have put the Custom Code into "View As" on the List page has to be specifically identified by name and that particular record value retrieved to be evaluated in your Custom Code.
For instance, if the field in each of your records was named "count" where the 0, 1, 2, 3 .... would be displayed then your code should look something like this ---



if ($data["count"]=='0'){

$value="<img src=\"images/red_ball.gif\">";

}

if ($data["count"]=='1'){

$value="<img src=\"images/greensquare.png\">";

}

if ($data["count"] >'1')

$value="<img src=\"images/ledorange.png\">";


So, if the field where you get the "value" from is called "qty" for Quantity of items
Then you should make your "View As" custom code in the "qty" field read --



if ($data["qty"]=='0'){

$value="<img src=\"images/red_ball.gif\">";

}

if ($data["qty"]=='1'){

$value="<img src=\"images/greensquare.png\">";

}

if ($data["qty"] >'1')

$value="<img src=\"images/ledorange.png\">";



Take note that I changed the name of your images. To Test the code make sure to make the image names match to your own images.