Get the number of columns for the most recent query in PHP
Description
The following code shows how to get the number of columns for the most recent query.
Example
//from w w w . j a v a 2s . c om
<?php
$con=mysqli_connect("localhost","root","","test");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"SELECT * FROM employee");
// Get number of columns - will always return 3
mysqli_field_count($con);
mysqli_close($con);
?>