mysql_field_type()
string mysql_field_type(results,index)
This function returns the column data type for a field from the results set given. To specify a particular field, give an offset as the second argument. Here is an example:
...
$sql_stmnt = "SELECT * FROM workreq LIMIT 1";
$results = mysql_query($sql_stmnt);
$num_fields = mysql_num_fields($results);
for ($index = 0; $index < $num_fields; $index++) {
$name = mysql_field_name($results, $index);
$type = mysql_field_type($results, $index);
print "$name - $type \n";
}
...In this example, after one row of data is selected as a sample,
mysql_num_fields() determines the number of
rows in the results set so that a counter limit may be set up
($num_fields) in the for
statement that follows. Within the for statement,
the name of the field is extracted using
mysql_field_name() and the data type using
mysql_field_type(). Here are a few lines of
the output of this script:
wrid - int wr_date - date clientid - string ...