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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gpittingale
Forum Newbie
Posts: 12
Joined: Fri Jan 23, 2009 5:58 am

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

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

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

Post 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.
Post Reply