Page 1 of 1

how to retirieve field name

Posted: Tue Feb 13, 2007 3:15 pm
by markedagain
Hey guys,

i started creating a simple component(first one) and im wondering
if there is a function i can call to retrieve the field names of a table and manage to echo them using a for each loop?

M.

Re: how to retirieve field name

Posted: Tue Feb 13, 2007 9:55 pm
by davidwhthomas

Code: Select all

global $database;

$tables[] = '#__content'; //put table name here

$field_array = $database->getTableFields($tables); //get the field data

foreach($field_array as $field_data){ //loop through field data

	foreach($field_data as $field => $value){ 

	   print "Field: ".$field. "<br />"; //echo the field name

	}

}

Re: how to retirieve field name

Posted: Mon Feb 19, 2007 2:45 pm
by markedagain
sweet, thx so much dave.

following up on your answer i posted another question in the dev forum, maybe you might be able to assist me there also.

thank you very much.

http://forum.joomla.org/index.php/topic,142610.0.html

Re: how to retirieve field name

Posted: Mon Dec 02, 2013 8:54 pm
by MAtkins
davidwhthomas:
Thank You!! I've been looking for this for hours and here you are with the answer.

I tried what looks like the same code but I must have had something wrong.
I think I didn't realize that the param in getTableFields is an array.
The docs are unclear about it.

Works now! Thanks again.