Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

API function -- mysql_field_count()  with use of PHP

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Read about why website design really matters in today's demanding market.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

829 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