PHP Manual
Prev |  | Next

# mysql_field_type

mysql_field_type -- Get the type of the specified field in a result

## Description

`string mysql_field_type`(int result, int field_offset);

mysql_field_type() is similar to the mysql_field_name() function. The arguments are identical, but the field type is returned. This will be one of "int", "real", "string", "blob", or others as detailed in the MySQL documentation.

Example 1. mysql field types

      1
      2 <?php
      3 mysql_connect("localhost:3306");
      4 mysql_select_db("wisconsin");
      5 $result = mysql_query("SELECT * FROM onek");
      6 $fields = mysql_num_fields($result);
      7 $rows   = mysql_num_rows($result);
      8 $i = 0;
      9 $table = mysql_field_table($result, $i);
     10 echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
     11 echo "The table has the following fields <BR>";
     12 while ($i < $fields) {
     13     $type  = mysql_field_type  ($result, $i);
     14     $name  = mysql_field_name  ($result, $i);
     15     $len   = mysql_field_len   ($result, $i);
     16     $flags = mysql_field_flags ($result, $i);
     17     echo $type." ".$name." ".$len." ".$flags."<BR>";
     18     $i++;
     19 }
     20 mysql_close();
     21 ?>
     22

For downward compatibility mysql_fieldtype() can also be used.

Prev | Home | Next
mysql_field_table | Up | mysql_field_flags