This topic is locked

When to show percentages

6/28/2006 6:37:42 AM
PHPRunner General questions
O
osluk author

Hi folks,
Often data might have N/A or none in it.

This then screws up searches so I have tried to ensure the numeric fields are eith valid data or blank.

If it is zero then zero is the actual figure not a default figure.
With percentage fileds if there is no data to show I relly need the field to be blank.

Not knowing if there was an increase in price is very different from 0% no difference.
As we have more records there are certain to be incomplete sections where there is no data

to calculated a price difference for example.
Any ideas how best to tackle this?
Cheers Chris
As always Sergy and the team you are stars and the product great!

O
osluk author 6/28/2006

Hi I have the percentages working great now see the screengrabs below.
Is it possible to choose the number of decimal palces displayed.

In some instances whole number would be fine other 2 or 3 places would be good.


Perfect


Ideally only display recorded with a meaningful % prices in one or both colums.

Fancy query of have a new field checkbox poulated if data is good.
Any other ideas.
Chris

Alexey admin 6/28/2006

Chris,
here is the code snippet in include\..._functions.php file you can edit to change Percentages display

else if($format == FORMAT_PERCENT)

$ret = ($data[$field]*100)."%";


I.e. this code will display integer part only:

else if($format == FORMAT_PERCENT)

$ret = round($data[$field]*100)."%";

O
osluk author 6/28/2006

Might to cool to add the choice of the decimal places to the wish list.
Is there a way to have a null entry if the percentage is not calculated

  • ie no valid data to make the calculation?
    Cheers Chris

    Thanks for the snippet
    Currently 123%

    will not align with 143.34%
    Can I fix the number of decimals so they all display
    123.00%

    143.34% etc


Before snippet <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=9470&image=2&table=forumreplies' class='bbc_emoticon' alt=':(' />
After snippet


Great job!!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=9470&image=4&table=forumreplies' class='bbc_emoticon' alt='B)' />

Alexey admin 6/29/2006

Chris.
here is the code to show two decimal places if percentage is calculated and "N/A" otherwise.

else if($format == FORMAT_PERCENT)

{

if($data[$field])

$ret = round($data[$field]*100,2)."%";

else

echo "N/A":

}

O
osluk author 6/29/2006

That is almost perfect thanks Alexa.

What I want is the % field to be blank - no 0%
As PHP is not very forgiving
what do I need to do to this line
echo "N/A":
to made the field blank or null
Cheers Chris
I really appreciate your help.

O
osluk author 6/29/2006

Chris.

here is the code to show two decimal places if percentage is calculated and "N/A" otherwise.


I could be wrong but when I got the following error message

Parse error: syntax error, unexpected ':', expecting ',' or ';' in /hsphere/local/home/bauduc-dev/bordeauxreport.com/db-2005/AdminD/include/data_functions.php on line 742
I tried changing
the : to a ;
and now it works great.



Note the entry where the price is not supplied shows N/A - perfect
Not the previous 0% which implied the price has not changed when we actually

dont know if there was a change or not!
Cheers Chris
Great product and great support as always!