RE: [PHP] Re: eval()
| From: | Alex Dowgailenko | Date: | Mon, 21 Jan 2002 04:17:30 +0000 |
| Subject: | RE: [PHP] Re: eval() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81319@lists.php.net to get a copy of this message | ||
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.....