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 7615015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:33:02+00:00 2026-05-31T02:33:02+00:00

quick question… my sql query is spitting out this data… Array ( [id] =>

  • 0

quick question… my sql query is spitting out this data…

Array ( [id] => 1 [name] => Test Name [text] => This is text [image] => image.jpg ) 

When there are two rows of data, is there something wrong with my php code?

$query = "SELECT id, name, text, image FROM categories";
    $results = mysql_query($query, $connection);
    $results = mysql_fetch_assoc($results);
  • 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-31T02:33:03+00:00Added an answer on May 31, 2026 at 2:33 am

    mysql_fetch_assoc fetches one row at a time. You need to loop over the result set:

    while(false !== ($row = mysql_fetch_assoc($results))){
        [handle $row here]
    }
    

    From the docs (search is your friend):

    Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows.

    If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the same name, you either need to access the result with numeric indices by using mysql_fetch_row() or add alias names. See the example at the mysql_fetch_array() description about aliases.

    Cheers

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

Sidebar

Related Questions

quick question, I have a <hr> and this script: <script type=text/javascript > $(function ()
Quick question about the TransactionScope object. Found this on the internet: When you access
Quick question: is this kind of nesting possible? An if statement first passing a
Quick question, having a look around it seems this is the case, but it
Quick question here about short-circuiting statements in C#. With an if statement like this:
quick question, what's the best way to convert language a abbreviation to full name?
Quick question. If I have an array and have properly overloaded the assignment operator,
Quick question if anyone has time to answer. The current query works great, but
Quick question. Our apple developer distribution certificate expires at the end of this month.
Quick question. What do you think, I have a few sites that use a

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.