fetch_lengths
Returns the column length of the current row in the result set.
lengths
/ mysqli_fetch_lengths()
function returns the field length of the current row in the result set.
Returns the field length of the current row in the result set:
<?php $mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ; if ( $mysqli -> connect_errno ) { echo "Failed to connect to MySQL: " . $mysqli -> connect_error ; exit ( ) ; } $sql = "SELECT * FROM Persons ORDER BY Lastname" ; if ( $result = $mysqli -> query ( $sql ) ) { $row = $result -> fetch_row ( ) ; // Show field length foreach ( $result -> lengths as $i => $val ) { printf ( "Field %2d has length: %2d\n" , $i + 1 , $val ) ; } $result -> free_result ( ) ; } $mysqli -> close ( ) ; ?>
Returns the field length of the current row in the result set:
<?php $con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ; if ( mysqli_connect_errno ( ) ) { echo "Failed to connect to MySQL: " . mysqli_connect_error ( ) ; exit ( ) ; } $sql = "SELECT * FROM Persons ORDER BY Lastname" ; if ( $result = mysqli_query ( $con , $sql ) ) { $row = mysqli_fetch_row ( $result ) ; // Show field length foreach ( mysqli_fetch_lengths ( $result ) as $i => $val ) { printf ( "Field %2d has length: %2d\n" , $i + 1 , $val ) ; } mysqli_free_result ( $result ) ; } mysqli_close ( $con ) ; ?>