After getting very frustrated with arrays, I ended up using eval() in the following way:
function top10() { $i = 0; $res = mysql_query("SELECT orders.pid, products.pid, orders.amount, products.pname FROM orders, products WHERE orders.uid!='' AND orders.pid=products.pid") or die(mysql_error()); while (list($opid, $ppid, $amount, $pname) = mysql_fetch_row($res)) { $eval = '$temp["'.$pname.'"] = $temp["'.$pname.'"] + '.$amount.';'; eval($eval); $i++; } arsort($temp); return $temp; } It works fine for me, though I don't really need to select orders.pid and products.pid since they aren't used. They are there when I was debugging but *shrug*, I'm just too lazy to remove them right now! Alex..... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]