This topic is locked

Newbie: Help with IF functions?

4/11/2008 10:09:45 PM
PHPRunner General questions
N
nickrix author

Is it possible (and easy - im a newbie) to be able to display a picture based on the content of a feild?
EXAMPLE:

In my database i have got a column where there is a score from 1-100 - i want to display 1 of 3 images based on the score, so lets say if score is between 1 - 30 show image a.gif if score is between 31- 70 show image b.gif or if score is 71-100 show image c.gif
whats the best way to do this?
also...
whilst on the subject of ifs.

Is it possible only to show a link to another table (linked by key) if there is data in the table it is linked too?

example for this would be, table 1 = comapanies & table 2 = contacts
on the comapnies view, only display a link to contacts if the contacts primary id is same as companies primary id.

Hope this makes sense.
anyone got any sample code?
thanks for your help, in advance.
Nick

J
Jane 4/14/2008

Nick,
use custom format on the "View as" settings dialog on the Visual Editor tab.

Here is a sample:

if ($value>0 && $value<31)

$value = "<img src=\"1.gif\" border=0>";
if ($value>30 && $value<71)

$value = "<img src=\"2.gif\" border=0>";
if ($value>70 && $value<101)

$value = "<img src=\"3.gif\" border=0>";


Regarding the second question.

Please check this thread:

http://www.asprunner.com/forums/index.php?showtopic=8071