Page 1 of 1

Can anyone pl give me a basic example of mathfunction in php

Posted: Mon Jan 26, 2009 8:27 am
by gpittingale
Hi there seen as i have come a custom for asking for help here, i was wondering if any body could give me a basic example of a mathamatical function that calls array's from mysql to a php script and then does a basic maths sum with them. would appreciate the help with this
Thanks in Advance

Re: Can anyone pl give me a basic example of mathfunction in php

Posted: Mon Jan 26, 2009 11:49 am
by John Cartwright
I'm not exactly sure what you are asking, but it is usually better to perform any calculations on the database than PHP.

A simple example being,

Code: Select all

SELECT SUM(fieldname) FROM yourtable
The equivilent in php, if you have an array of values is array_sum()

You need to be more specific in your question.