PHP mysqli_field_count() Function

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


int mysqli_field_count(connection);

mysqli_field_count() Function Parameter

result :Required parameter. Mention a result set identifier returned by mysqli_query().

mysqli_field_count() Function Return Value

Return Values :Returns an integer that represents the number of fields or columns in the result set.

mysqli_field_count() Function Example

$con = mysqli_field_countt("localhost","user","password","db");

if (mysqli_connect_errno())
	echo "Failed to connect to MySQL: " . mysqli_connect_error();

$sql = "SELECT * FROM employee";
$sql_result = mysqli_query($con, $sql);

echo "Total number of columns " . mysqli_field_count($con);