mysqli_fetch_lengths() : field length

$result_set->lengths;
mysqli_fetch_lengths
The input parameter $result_set is the output of result set identifier of mysqli_query(), mysqli_store_result() or mysqli_use_result().

The output is an array containing legth of all columns of result set row .

MySQLI database connection file

Example : Object Oriented Style
<?Php
require "config.php";// Database connection file.

$query="select * from student where id=7 ";
if ($result_set = mysqli_query($connection,$query)) {
	 $row = mysqli_fetch_row($result_set);
echo $row[1]."<br>";
foreach (mysqli_fetch_lengths($result_set) as $i => $val) {
	echo " Field No ". $i ." value: ".$val . ",";
  }   
}
?>
Krish Star
Field No 0 value: 1, Field No 1 value: 10, Field No 2 value: 4, 
Field No 3 value: 2, Field No 4 value: 6,

MySQL SELECT Query

Procedural style
<?Php
require "config.php";// Database connection file.
$q="SELECT * FROM student where id=4";
if ($result = $connection->query($q)){
    
$row = $result->fetch_row();

echo $row[1]."<br>";
  foreach ($result->lengths as $i => $val) {
   echo " Field No ". $i ." value: ".$val . ",";
  }
	
 $result->close();
}
?>

MySQL DUMP of student table

Visitors Rating
Your Rating





Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer