[ListFields Params]Database Tags[/ListFields]
Lists all the fields in the specified database, SQLResult record set, or SQL table

To display a list of all the fields in a particular database, put a [ListFields] context into a template. You may put a [ListFields] context inside the [ListDatabases] context to automatically list all the fields in all the databases.

Example (normally you would put the following text into a .tpl file on your server and use a web browser to link to it):

[ListDatabases]
Fields in database [name]:<br>
[ListFields db=[name]]
Fieldname: [FieldName]<br>
[/ListFields]
<hr>
[/ListDatabases]

Starting in WebDNA 6.0...

To display a list of all fields in an SQL table (after a [SQLConnect] context), specify the SQL connection and database table.

Example


The "inventory" table has the following fields:<br>
[ListFields conn_ref=conn1&table=inventory]
<b>[fieldname]</b><br>
<li>ordinal: [ordinal]</li>
<li>datatype: [datatype]</li>
<li>allownull: [allownull]</li>
<li>width: [width]</li>
<br>
[/ListFields]
		

To display a list of all fields in a [SQLResult] record set, just include the [ListFields] inside of a [SQLResult] context.

Example


[SQLResult result_ref=rs1]
The result set from query "select * from employees;" has [numFields] fields:<br>
[ListFields]
<b>[fieldname]</b><br>
<li>ordinal: [ordinal]</li>
<li>datatype: [datatype]</li>
<li>allownull: [allownull]</li>
<li>width: [width]</li>
<br>
[/ListFields]
<br>
[/SQLResult]
		

The following tags are available inside a [ListFields] context:
Tag Description
 [FieldName]
 the name of the field.
[Index]
A number from 1 to the total number of fields, indicating this field's index placement in the list.
The following tags are available when using [ListFields] to list SQL fields
[ORDINAL]
Will retrieve the literal position of the current iterated field.
[DATATYPE]
Will retrieve the named SQL datatype of the current iterated field.
[ALLOWNULL]
Returns whether or not (T or F) the current iterated field will accept a null value as a possible entry/value.
[WIDTH]
Will retrieve the maximum length of data the current iterated field will allow.