Use mySQL and PHP to manipulate data and sort by a NEW variable created in PHP?

jack

New member
Is there a way to take data from a mySQL query, create an array (in PHP), manipulate the data, create a new variable then order all of the query by this NEW variable?

eg in the table there are 100 unique entries (primary key) each of which has 10 (random) numbers, number1, number2, number3 and so on. I want to order (on the webpage) each unique entry by the average of all their associated numbers. I'm sure this should be straight forward!
Currently I am just getting the data, finding the average for each entry, then uploading the entryid and average into a new mySQL table called averages. Then when all are calculated and inserted, querying this new table, with SELECT * FROM averages ORDER BY average. Then displaying this as the end result.
Bit too long winded, plus if multiple users access this page, I have had a situation where only half of this 'averages' table has been returned as a second user is also 'using' it.

Any ideas? More info on request.

Cheers, Jack
 
Back
Top