View Single Post
  #2  
Old 09-13-2006, 11:11 AM
stranger stranger is offline
OSP Starters
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
stranger is on a distinguished road
Default

I think I'can help you, except your data above isn't coming from an array, but anyways:
PHP Code:
<?php if ($row['sales']!=0){
$gp=$row['gp']/$row['sales'];
}
else {$gp=0;} ?>

we still need to change $gp into a percentage...how many decimal places do you want? Here it is rounded to two decimals of a percentage:
PHP Code:
<?php
$gp=round($gp,4);
$gp=$gp*100;
echo $gp . "%";
?> -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - How would I do this in PHP?
View Single Post
  #2  
Old 09-13-2006, 11:11 AM
stranger stranger is offline
OSP Starters
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
stranger is on a distinguished road
Default

I think I'can help you, except your data above isn't coming from an array, but anyways:
PHP Code:
<?php if ($row['sales']!=0){
$gp=$row['gp']/$row['sales'];
}
else {$gp=0;} ?>

we still need to change $gp into a percentage...how many decimal places do you want? Here it is rounded to two decimals of a percentage:
PHP Code:
<?php
$gp=round($gp,4);
$gp=$gp*100;
echo $gp . "%";
?> -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote