What is mysql_field_flags() function in PHP?
How does mysql_field_flags() 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 if (!mysql_select_db("my_database", $link)) { echo " ERROR NO: " . mysql_errno($link) . "n"; } $query="select * from my_table"; $result=mysql_query($query,$link); // display flags of first field $field_flag=mysql_field_flags($result,0); // used explode to break the result with single space $ff=explode(' ',$field_flag); while (list ($key, $val) = each ($ff)) { // displaying the flags echo "$key -> $val <br>"; } mysql_close($link); ?> |
<?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 if (!mysql_select_db("my_database", $link)) { echo " ERROR NO: " . mysql_errno($link) . "n"; } $query="select * from my_table"; $result=mysql_query($query,$link); $i = 0; //loop till end of fields in result handle while ($i < mysql_num_fields ($result)) { //fetch field names in result handle $row = mysql_fetch_field ($result); //print field names in result handle echo "$row->name <br>"; //fetch flags of each fields in result handle $field_flag=mysql_field_flags($result,$i); $ff=explode(' ',$field_flag); while (list ($key, $val) = each ($ff)) { //print flags of all the fields in result handle echo "$key -> $val <br>"; } $i++; } mysql_close($link); ?> |