That is indeed a very bad way of doing it, but you could atleast remove these two lines:
$id = $result_totalrow['id'];
$value = $result_totalrow['value'];
because that is completely unrelated to anything and is completely logically (you're treating a resource as an array) 😛 There is also no need for the $k variable, all it is doing is pushing your indices one up, which is completely unneccessary (it's not hard to add a "-1" when you're getting the value). And, like laserlight has said, if you're not going to use your array later in the script then it is silly taking all of the values out of the table. Oh and that loop that you do for each row is completely unneccessary, just change mysql_fetch_array to mysql_fetch_assoc and use:
$array[] = $total;
which should have the same effect.