What is mysql_field_type() function in PHP?
How does mysql_field_type() works?
<?php // Attempt to connect to the default database server $link = mysql_connect("mysql_host", "mysql_user", "mysql_password")or die ("Could not connect"); //select database $db_select = mysql_selectdb("mydb",$link);//returns result set on executing the query $result=mysql_query("select * from user",$link);// return specified field type $type = mysql_field_type($result, 0); //display field type echo "Field type:$type <br>";?> |
<?php // Attempt to connect to the default database server $link = mysql_connect("mysql_host", "mysql_user", "mysql_password")or die ("Could not connect"); //select database $db_select = mysql_selectdb("mydb",$link);//returns result set on executing the query $result=mysql_query("select * from user",$link); //function returns number of fields in the recordset $fields_no = mysql_num_fields($result);$i = 0; while ($i < $fields_no) { // return name of the field using mysql_field_name $name = mysql_field_name ($result, $i); // return field type using mysql_field_type $type = mysql_field_type ($result, $i); //display field name and data type of the field echo "Field name:$name--Field Type: $type <br>";$i++; } ?> |