What is the function in PHP to retrieve the number of columns in a MySQL query result?
When executing a MySQL query in PHP, you may need to retrieve the number of columns in the query result for further processing. To achieve this, you can use the `mysqli_num_fields()` function in PHP. This function takes the result set as a parameter and returns the number of fields (columns) in the result set.
// Assuming $result is the variable holding the MySQL query result
$num_columns = mysqli_num_fields($result);
echo "Number of columns in result: " . $num_columns;