ok, here we go :
table name : item
fields : id, code, data, missedtargets, variance
data :
1, aas7, 5, 44
2, aas5, 5, 14
3, aas4, 5, -34
4, aas2, 4, 26
5, aas1, 4, -44
6, aas1, 4, 9
7, aas1, 4, 10
8, aas1, 3, 123
9, aas1, 3, -87
10, aas1, 3, -12
11, aas1, 3, 13
relevant code :
$db->query("SELECT * FROM item");
while ($db->next_record()){
$code = $db->field("code");
$data = $db->field("data");
$missedtargets = $db->field("missedtargets");
$variance = $db->field("variance");
$final_array[$code]["code"] = $code;
$final_array[$code]["data"] = $data;
$final_array[$code]["missedtargets"] = $missedtargets;
$final_array[$code]["variance"] = $variance;
};
heres how id like to output the data :
1, aas7, 5, 44
2, aas5, 5, 14
3, aas4, 5, -34
4, aas2, 4, 26
6, aas1, 4, 9
7, aas1, 4, 10
5, aas1, 4, -44
8, aas1, 3, 123
11, aas1, 3, 13
10, aas1, 3, -12
9, aas1, 3, -87
ordered by missed targets, then variance.
looking at the array_multisort() function, i cant really see how id get it to do what i want... but it needs to.
there is no other option, believe me. before adding into the array, im altering the missedtargets and variance data, making it impossible to get mysql to sort it by these fields (as the order will change as soon as i make my alterations to the data).
iv tried :
array_multisort ($final_array[]["missedtargets"], SORT_NUMERIC, SORT_DESC,
$final_array[]["variance"], SORT_NUMERIC, SORT_DESC);
but as expected, it doesnt know what to do with '[]'.
help?