Hi there seen as i have come acustom 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!

Member Avatar for diafol

What do you mean calls arrays? Does your mysql field hold array-type data, e.g. 1,5,8,9? Do you want the result written to the mysql table? You can certainly do simple maths with just MySQL query, no need to use php, e.g.

SELECT 
myfield, IF(someotherfield <> 0,somotherfield*2,0) AS myresultfield
FROM
mytable

The above with provide a recordset with two fields: "myfield" and "myresultfield". The "myresultfield" will have a value of 0 if the field, "someotherfield" is 0, otherwise it will have a value of "someotherfield" multiplied by 2. The "myresultfield" is known as a calculated field. You can build very complex mathematical expressions and functions using MySQL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.