This topic is locked

changing color of displayes data

10/28/2005 7:50:46 AM
PHPRunner General questions
scuba author

In a table of integer values (0 and 1 for true or false) I would like to display the 0-values in blue and the 1-values in red and set to bold. Guess I'll have to change some PHP but what and where?
thanks in advance

scuba author 10/28/2005

... and is there a way to make the 0-values not appear at all?

admin 10/28/2005

Hi,
You should modify ..._list.php file.

Find the following fragment of code inside LoopRS function:

<TD>

<?php

$iquery="field=".array_search("FIELD",$fieldlist)."&key=".htmlspecialchars($data[$strKeyField]);

if($strKeyField2)

  $iquery.="&key2=".htmlspecialchars($data[$strKeyField2]);

if($strKeyField3)

  $iquery.="&key3=".htmlspecialchars($data[$strKeyField3]);

?>


where FIELD is your actual field name.
Replace <TD> with:

<TD

<?php

if($data["FIELD"]==1)

 echo 'bgcolor=red style="font-weight : bold" ';

else

 echo 'bgcolor=blue ';

?>

>


To prevent 0-values from displaying, put the following just before $iquery=... line:

if($data["FIELD"]==0)

 $data["FIELD"]="";



Please note that Field names are case-sensitive here.