array problem

From: Date: Thu, 20 Jun 2002 15:11:38 +0000
Subject: array problem
Groups: php.db 
Request: Send a blank email to php-db+get-19905@lists.php.net to get a copy of this message
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

« previous php.db (#19905) next »