View Single Post
  #1  
Old 09-13-2006, 11:05 AM
jaffer jaffer is offline
OSP Starters
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jaffer is on a distinguished road
Default How would I do this in PHP?

hi all.
I need to divide two elements in my array to reach a percentage. Normally this is easy to do but one of the elements is sometimes zero which generates an error message. I'm not sure how to overcome this in PHP.
In SQL I'd do something like this

CASE WHEN $row[sales] <> 0
THEN $row[gp]/$row[sales]
ELSE '0'
END AS gp percent
How would I do this in PHP?

Thanks
BJ -- 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
  #1  
Old 09-13-2006, 11:05 AM
jaffer jaffer is offline
OSP Starters
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jaffer is on a distinguished road
Default How would I do this in PHP?

hi all.
I need to divide two elements in my array to reach a percentage. Normally this is easy to do but one of the elements is sometimes zero which generates an error message. I'm not sure how to overcome this in PHP.
In SQL I'd do something like this

CASE WHEN $row[sales] <> 0
THEN $row[gp]/$row[sales]
ELSE '0'
END AS gp percent
How would I do this in PHP?

Thanks
BJ -- 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