Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

mysql_field_len()

Synopsis

int mysql_field_len(results, index)

This function returns the length from a field of the results set given. Specify the desired field via the index in 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++) {
  $field_name = mysql_field_name($results, $index);
  print "$field_name - " .
         mysql_field_len($results, $index) . "\n";
}
...

Here, one row has been retrieved from a table and mysql_num_fields() determines the number of fields in the results set. With a for statement, each field is processed to determine its name using mysql_field_name() and the length of each field is ascertained with mysql_field_len(). Here are a few lines of the output of this script:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint