Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:49:04+00:00 2026-05-16T11:49:04+00:00

Here is a line of my code while($row = mysql_fetch_array($result)) I want to get

  • 0

Here is a line of my code

while($row = mysql_fetch_array($result))

I want to get how many columns are in the row. I tried count($row) but this returned what I think is the number of cells for the whole $results.

i.e there are actually 7 columns, and 2 rows and count($row) returned 14. I want a function that will return 7.

Can you see where I’m going wrong.

Thanks in advance.

EDIT – Answer found

Passed MYSQL_NUM as a second parameter to mysql_fetch_array.
Thanks anyway to everyone’s answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:49:05+00:00Added an answer on May 16, 2026 at 11:49 am

    When you use mysql_fetch_array each row has the columns indexed twice, once by column number and once by column name. So count($row) will be twice the number of columns.

    Use mysql_fetch_row if you only want numerical indices, and mysql_fetch_assoc if you want name indices. These functions will both return rows with 7 entries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
I'm using the source code found on this site here: http://webtint.net/tutorials/5-star-rating-system-in-php-mysql-and-jquery/comment-page-1/#comment-2562 A fantastic resource,
Ok I'm dynamically generating the cell coordinates but I get this error, why? Error:
Okay well I apologize for how sloppy this code is, but I still cant
Here's the deal. Is there a way to have strings tokenized in a line
Are the any task tracking systems with command-line interface? Here is a list of
Python, through it's readline bindings allows for great command-line autocompletion (as described in here
Please help, I am stuck here --- irb> a = line of text\n line
I have a code for reading files with float numbers on line stored like
Here's my code: test.h @interface testAppDelegate : NSObject <NSApplicationDelegate> { NSWindow *window; IBOutlet NSTableView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.