davidj

05-22-2008, 10:22 AM

Hi

I have converted a PHP Array into a JS Array for performing calculations instead of doing multiple server calls and database queries

the JS Array result is multidimentional and looks like this

Results[0]['RecordID'] = '1';

Results[0]['BranchID'] = '0101';

Results[0]['Controller'] = '4';

Results[0]['Model'] = 'Skoda';

Results[0]['RegDate'] = '10 may 2006';

Results[0]['UnitSold'] = '1';

Results[0]['UnitSold'] = '9000.00';

a small example as there are 600+ numeric keys and 40 associative ones for each numeric

I am looking for an example of a function which could identify values from the ARRAY and return that numeric key so i can access the all the associative ones and peform calculations.

if you look at the example i need to find all occurances of every model. Say 'Skoda' and that it was sold and return the total cost for every result. (Performing calculations)

so if any associative keys match my query return the numeric key it was found in as each numeric key refers to a line of data.

also i have an array of models where i will need to use that to loop through and perform the same caculation for each model and posibly create a new array with the results

NewResults['Skoda']['SalesLast3Months'] = '29';

NewResults['Skoda']['SalesLast1Months'] = '2';

NewResults['Skoda']['CurrentStock'] = '2';

NewResults['Skoda']['TotalValue'] = '12000.05';

NewResults['Polo']['SalesLast3Months'] = '7';

NewResults['Polo']['SalesLast1Months'] = '3';

NewResults['Polo']['CurrentStock'] = '1';

NewResults['Polo']['TotalValue'] = '6050.05';

NewResults['Ka']['SalesLast3Months'] = '12';

NewResults['Ka']['SalesLast1Months'] = '5';

NewResults['Ka']['CurrentStock'] = '6';

NewResults['Ka']['TotalValue'] = '23000.10';

etc...

can you help with this?

I have converted a PHP Array into a JS Array for performing calculations instead of doing multiple server calls and database queries

the JS Array result is multidimentional and looks like this

Results[0]['RecordID'] = '1';

Results[0]['BranchID'] = '0101';

Results[0]['Controller'] = '4';

Results[0]['Model'] = 'Skoda';

Results[0]['RegDate'] = '10 may 2006';

Results[0]['UnitSold'] = '1';

Results[0]['UnitSold'] = '9000.00';

a small example as there are 600+ numeric keys and 40 associative ones for each numeric

I am looking for an example of a function which could identify values from the ARRAY and return that numeric key so i can access the all the associative ones and peform calculations.

if you look at the example i need to find all occurances of every model. Say 'Skoda' and that it was sold and return the total cost for every result. (Performing calculations)

so if any associative keys match my query return the numeric key it was found in as each numeric key refers to a line of data.

also i have an array of models where i will need to use that to loop through and perform the same caculation for each model and posibly create a new array with the results

NewResults['Skoda']['SalesLast3Months'] = '29';

NewResults['Skoda']['SalesLast1Months'] = '2';

NewResults['Skoda']['CurrentStock'] = '2';

NewResults['Skoda']['TotalValue'] = '12000.05';

NewResults['Polo']['SalesLast3Months'] = '7';

NewResults['Polo']['SalesLast1Months'] = '3';

NewResults['Polo']['CurrentStock'] = '1';

NewResults['Polo']['TotalValue'] = '6050.05';

NewResults['Ka']['SalesLast3Months'] = '12';

NewResults['Ka']['SalesLast1Months'] = '5';

NewResults['Ka']['CurrentStock'] = '6';

NewResults['Ka']['TotalValue'] = '23000.10';

etc...

can you help with this?