[PHP-DB] array problem From: Mike Hughes (m.hughes <email protected>)
Date: 06/20/02

Hi, I am carrying out MySQL queries and putting the results into arrays for
easy handing in PHP. However, I have a small problem. I want to
automatically display the query result by printing out the array using a
simple for each loop like so:

$result = mysql_query($query);
$row = mysql_fetch_array($result);
foreach($row as $key => $val) {
   if ($val != NULL){
     echo "$key is set to $val<br>";
   }
}

but when I do this I get two entries for each field, one with the numerical
key and the other with the field name key.

0 is set to field1data
field1name is set to field1data
1 is set to field2data
field1name is set to field2data
etc ..

How to just get the output with the field names?
Mike

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php