This topic is locked
[SOLVED]

 Conditional formatting

10/29/2007 6:38:12 AM
PHPRunner General questions
O
osluk author

I have studied this post from Jane.
http://www.asprunner.com/forums/index.php?showtopic=5163
I have a database where prices of wine from 2006 are compared to current price
http://www.bordeauxreport.com/db-2007/view...hange%5Fpercent
There are 2 fields in question as follows

`Price Oct 2007GBP`-`Release Price in 2006 GBP`AS`07_change_release`,

(`Price Oct 2007GBP`-`Release Price in 2006 GBP`)/`Release Price in 2006 GBP`AS`07_change_percent`
I think the following would be best to use the following criterion on the `07_change_percent` value

less than zero % change RED

zero to 4.9% ORANGE

5% increase and above GREEN
Might be good to conditionally format both the `07_change_release` & `07_change_percent` fields but the conditional formatting be based on the rules for the percentage change!
Some pointers would be great because it seems to be possible in principal.
I already have the following to add the currency sign add 1000 seperator and have no decimal places.

Should this stay first?
Cheers Chris

J
Jane 10/30/2007

Chris,
you can use the second code snippet from above post in your project.

O
osluk author 10/30/2007

Thanks Jane
global $data;

$str = "<font color=";

if ($data["07_change_percent"]=="0")

$str.="red";

if ($data["07_change_percent"]=="<>0")

$str.="green";

str.=">".$value."</font>";

$value=$str;
Parse error: syntax error, unexpected T_CONCAT_EQUAL in /hsphere/local/home/bauduc-dev/bordeauxreport.com/db-2007/view/include/commonfunctions.php on line 404
I wanted to do the following but thought I would use 0 & not 0 initially not sure what the sytax of the following would be
less than zero % change RED

zero to 4.9% ORANGE

5% increase and above GREEN
Just to complicate things this was dispalyed as a percentage
In this image once i removed the prolem code the % formatting was lost


To keep the % formatting and use custom code what do I need to add to apply the % formatting.


Cheers Chris

O
osluk author 11/2/2007

Can anyone help with this.
Display test font for field red orange or green and displayed as a percentage format
if
less than zero % change RED

zero to 4.9% ORANGE

5% increase and above GREEN
Thanks Chris

J
Jane 11/6/2007

Chris,
here is he correct code:

global $data;

$str = "<font color=";

if ($data["07_change_percent"]==0)

$str.="red";

if ($data["07_change_percent"]!=0)

$str.="green";

str.=">".$value."</font>";

$value=$str;


Also I recommend you to learn some PHP so you can implement this on your own:

http://php.net/manual/en/

O
osluk author 11/7/2007

Hi Jane thanks for your help
I added the $ in red which seemed to cure the error
Parse error: syntax error, unexpected T_CONCAT_EQUAL in /hsphere/local/home/bauduc-dev/bordeauxreport.com/db-2007/view/include/commonfunctions.php on line 392
global $data;

$str = "<font color=";

if ($data["07_change_percent"]==0)

$str.="red";

if ($data["07_change_percent"]!=0)

$str.="green";

$[size="3"][/size]str.=">".$value."</font>";

$value=$str;
Shows colour is changed but percentage format is lost



Also zero value is red but less than zero is green
BTW I have search the PHP documentation and google for PHP calcualte a percentage etc - what do I need to search for?
Cheers Chris

global $data;

$str = "<font color=";

if ($data["07_change_percent"]==0)

$str.="red";

if ($data["07_change_percent"]!=0)

$str.="green";

$str.=">".$value."</font>";

$value=$str;