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

  • SEARCH
  • Home
  • 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 9087903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:48:12+00:00 2026-06-16T21:48:12+00:00

I have troubles to understand the use of while($row = mysql_fetch_array($query)) to display some

  • 0

I have troubles to understand the use of

while($row = mysql_fetch_array($query))

to display some elements of a database that are in the variable “$query”.
Moreover, I dont understand what is passed to the variable “$row” by the function “mysql_fetch_array()”.
My guess is that only one record (or row) of the database records that are in “$query” is given, but how does the function know which row??

I’ll try to explain myself using an example.

Assuming I have 3 records in the variable $query with two fields (say “id” and “name”).
At the first while the variable $row is filled by the first element (say id=1, name=antonio), then some code allow me to display or manipulate “1” and “antonio”, then the code ends and the while starts again.

Now I assume that what is given to the variable “row” is the second element, but how does the function knows that must return the second element (and not the first one or the third one)?? I mean, I dont give this information anywhere…

  • 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-06-16T21:48:13+00:00Added an answer on June 16, 2026 at 9:48 pm

    The variable $query is a resource and as such, has some sort of internal “row counter”. Every time you call mysql_fetch_array() or a variant thereof, this counter gets incremented. As a result, every time you call this function mysql_fetch_array, you get the next row. When the last row has been received, and you call it again, it returns false. Because of the way a while loop works, you break out of this loop.

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

Sidebar

Related Questions

Im currently having trouble trying to understand linked lists. I have some code that
I've been have trouble understand this problem. If I change the variable name fifthViewController
I have troubles with the following database design (simplified for the example). It allows
I have some troubles with my school project. I have a class: #include Group.h
I have some troubles with plotting the figure. I have a file with some
I have some troubles mapping a JSON Array to RestKit. This is what the
I have some troubles with getting the data from the website. The website source
I have some troubles with a method having a typed List parameter, inherited from
I currently have some trouble with the Heap in a program of mine. While
I am trying to start use Symfony2, and i have troubles with a first

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.