This problem started life as a javascript issue, but I think the solution is more php orientated.
I have created a function that takes its inputs passed from a loop.
[code=php]function despatch($ref, $product, $lngth, $wdth, $wt, $type){
//calculations here
}
The variables correspond to fields in MySQL recordset row. It calculates the delivery charges finishing with a variable called $fincharge. That bit works well. However, as I am calculating totals on the fly and not saving them in a table, I can not calculate the total delivery cost if there is more than one $fincharge because the function calculates a $fincharge for each item, returns the result, ‘forgets’ the result and then runs the function for the next item in the loop.
I have considered array_push, but I believe it raises a warning if the first input is not already an array.
Does anybody know how to create a sum of variables when each ‘list’ is of an unknown length and each variable effectively has the same name?
More info can be happily supplied.