Solved

API function -- mysql_field_count()  with use of PHP

Posted on 2002-07-22
2
433 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Read about why website design really matters in today's demanding market.
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 …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now