(PHP 3, PHP 4 , PHP 5)

mysql_fetch_field --  Get column information from a result and return as an object


object mysql_fetch_field ( resource result [, int field_offset])

Returns an object containing field information.

mysql_fetch_field() can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by mysql_fetch_field() is retrieved.

The properties of the object are:

Note: Field names returned by this function are case-sensitive.

Example 1. mysql_fetch_field() example

= mysql_connect('localhost:3306', 'user', 'password');
if (!
$conn) {
'Could not connect: ' . mysql_error());
$result = mysql_query('select * from table');
if (!
$result) {
'Query failed: ' . mysql_error());
/* get column metadata */
$i = 0;
while (
$i < mysql_num_fields($result)) {
"Information for column $i:<br />\n";
$meta = mysql_fetch_field($result, $i);
    if (!
$meta) {
"No information available<br />\n";
blob:         $meta
max_length:   $meta
multiple_key: $meta
name:         $meta
not_null:     $meta
numeric:      $meta
primary_key:  $meta
table:        $meta
type:         $meta
unique_key:   $meta
unsigned:     $meta
zerofill:     $meta

See also mysql_field_seek().

Sites of interest: Web Hosting : Reseller Hosting : Website Hosting : HTML Editor : Web Design Templates : Free Web Hosting : ASP code examples : PHP & MySQL Code Examples
  Copyright 2004 Evrsoft Developer Network. Privacy policy - Link to Us

Contact Evrsoft