Solved

API function -- mysql_field_count()  with use of PHP

Posted on 2002-07-22
2
461 Views
Last Modified: 2015-08-19
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
Comment
Question by:fr0x
2 Comments
 

Accepted Solution

by:
shifted earned 25 total points
ID: 7171115
So why don't you use PHP function mysql_num_fields() instead of C API?
0
 
LVL 8

Expert Comment

by:F P
ID: 40937507
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question