Extracting varable number of elements in a query to named arrays

From: Date: Mon, 16 Feb 2004 15:10:36 +0000
Subject: Extracting varable number of elements in a query to named arrays
Groups: php.db 
Request: Send a blank email to php-db+get-32960@lists.php.net to get a copy of this message
I have a SELECT query with a variable number of fields being included. When I come to extract them I get the wrong result with the following type of code as it does not 'accordian down' the list of variables - $a $b etc - which I equate to the named array I am trying to extract: while(list($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $q, $r)=mysql_fetch_array($result)) { $erefs[$z]=$a; $owners[$z]=$b; $addresss[$z]=$c; $contacts[$z]=$d; .... Eg if I don't look for 'owners' in the query I end up with $b being the addresses so that $addresss[$z]=$c; is a mismatch. Is there an entirely more adaptable way to extract the result into pre-defined array names with a variable number of fields in the query? Thanks, John

« previous php.db (#32960) next »