how to iterate over fields names with mysql_fetch_assoc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux