Try rhis: while ($row = mysql_fetch_assoc($result)) { foreach ($row as $fieldName -> $value) echo 'fieldName is: '.$fieldName."\n"; } hth Henrik Hornemann -----Oprindelig meddelelse----- Fra: grahama@xxxxxxxx [mailto:grahama@xxxxxxxx] Sendt: 19. juni 2004 22:26 Til: php-general@xxxxxxxxxxxxx; php-db@xxxxxxxxxxxxx Emne: how to iterate over fields names with mysql_fetch_assoc How do I iterate over fields when I perform the below script: each row has: artist_name,urlPath,biography as fields while ($row = mysql_fetch_assoc($result)) { # if the current field name is 'artist_name', do something switch($GetCurrentFieldNameintheCurrentRow) { case $row[ 'field name is now: artist_name'] //do something break; } If I write the below code, I only get the first field name of each row...which makes sense In this case, I get 'artist_name' while ($row = mysql_fetch_assoc($result)) { $fieldName= key($row); echo 'fieldName is: '.$fieldName."\n"; } many thanks :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php