You are here : phpmysqlimysqli_field_count

mysqli_field_count() - mysqli

The mysqli_field_count() function returns the number of columns for the most recent query.


Syntax

mysqli_field_count(connection);


Example

<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

mysqli_query($con,"SELECT * FROM Friends");
// Get number of columns - will always return 3
mysqli_field_count($con);

mysqli_close($con);
?>


Output / Return Value


Limitations


Alternatives / See Also


Reference