This topic is locked
[SOLVED]

 How to display an image instead og a value in list

5/12/2010 3:13:42 PM
PHPRunner General questions
C
cis2131 author

I have a list of websites, and i would like to show a little image (icon) in a cell showing if they are blocked or not.
e.g. if the value is "url" then i want to show one image, if it says "dom" another image.
I have this working:

if ($data["status"]=="url")

$row["rowstyle"]='style="background:Gainsboro"';
elseif ($data["status"]=="dom")

$row["rowstyle"]='style="background:red"';
else

$row["rowstyle"]='style="background:Palegreen"';
But would like icons in the status fields enstead...
Please advice.

A
ann 5/13/2010

Claus,
to show icons in cells open "View as" settings dialog on the Visual Editor tab. Choose Custom format and add your php code there.
Here is a sample:

if ($value=="url")

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

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

$value="<img src=\"images/custom_image3.gif\">";
J
Jepsen 5/13/2010

I often do this, but i use a different approach where i do not need to do any custom cone. ie.
I have a drop sown for "status" which can take 3 values; 1, 2 or 3
I have 3 images: 1.gif, 2.gif and 3.gif
And then I make the following query in MySQL:

concat("images/", `_medlemsregister`.`status`, ".gif") AS ikon,


The result is a field "ikon" which i format to image
that is the way I make all my "traffic lights"

C
cis2131 author 5/14/2010



Claus,
to show icons in cells open "View as" settings dialog on the Visual Editor tab. Choose Custom format and add your php code there.
Here is a sample:

if ($value=="url")

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

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

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



This works fine, thanks.. But it only works if there is a value in the field. blank values gets no logo.. i thougth it should have god the image3.gif..
Please advice

A
ann 5/14/2010

Claus,
this code should work for the fields with empty values also. Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

C
cis2131 author 5/15/2010

Thanks, but i think I wil try some more, before i upload it...