• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

API function -- mysql_field_count() with use of PHP

Hello, expert!

I have some problems with mySQL and PHP. I have found C API function in MySQL manual -
mysql_field_count() .

I wanted to ask you, how to use this API function in my php code. Is it possible? If not,
then can I ask you to write a reliable function, which could count fields in SQL query.

For example,

select * from ... ; How to count them ...??


This is my problem. Thanks in advance.

*j
0
fr0x
Asked:
fr0x
1 Solution
 
shiftedCommented:
So why don't you use PHP function mysql_num_fields() instead of C API?
0
 
F PCommented:
Like this with a sub-query, so it shows on every record, or independent if you just need it once.

SELECT table.*, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS  WHERE table_name = 'table') AS total_columns FROM table;

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now