You can call the mysql_stmt_field_count() function to return the number of columns for the most recent prepared statement.
Syntax
unsigned int
mysql_stmt_field_count(MYSQL_STMT *stmt)
Return values
An unsigned integer representing the number of columns in a result set is returned.
Errors
None.
Notes
The number of columns is 0 for statements that do not produce result sets, such as INSERT and DELETE. mysql_stmt_field_count() can be called after you have prepared a statement by calling mysql_stmt_prepare().