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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:09:13+00:00 2026-05-15T02:09:13+00:00

For instance, if I have the following table: +—-+—+———-+ | id | a |

  • 0

For instance, if I have the following table:

+----+---+----------+
| id | a | position |
+----+---+----------+
| 0  | 0 | 0        |
| 1  | 0 | 1        |
| 2  | 1 | 4        |
| 3  | 1 | 9        |
| 4  | 1 | 6        |
| 5  | 1 | 1        |
+----+---+----------+

and I want to get an array that contains the first 100 values from position where a is 1 in ascending order, what would I do?
Im guessing something like this:

$col = mysql_fetch_array( mysql_query('
SELECT `position`
FROM `table`
WHERE `a`="1"
ORDER BY `position` ASC
LIMIT 100
'));

I’d expect to get the following array:

+-------+-------+
| index | value |
+-------+-------+
| 0     | 1     |
| 1     | 4     |
| 2     | 6     |
| 3     | 9     |
+-------+-------+

but it doesn’t work.
¿What should I do to make it work?
Thanks

  • 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-15T02:09:13+00:00Added an answer on May 15, 2026 at 2:09 am

    mysql_fetch_array() gets a single row at a time from the result of your query. To access all of the rows you need a loop. Something like…

    while ($row = mysql_fetch_array($result, MYSQL_NUM)) 
    {
      printf("index: %s  value: %s", $row[0], $row[1]);  
    }
    

    I would take a closer look at: http://php.net/manual/en/function.mysql-fetch-array.php

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

Sidebar

Related Questions

I have the following model and instance: class Bashable(models.Model): name = models.CharField(max_length=100) >>> foo
I have the following code in config: <?php return array( 'di' => array( 'instance'
I have written the following Utility class to get an instance of any class
I have the following schema (generated from an existing table with the schema module
Lets say I have the following query. SELECT stringdata FROM table ORDER BY FIELDS(
Say for Instance I have the following table (full of connections between members) connectionA
I have the following problem: A framework generates a class from DB table, each
I have the following multi-table inheritance situation: from django.db import Models class Partner(models.Model): #
Say I have the following table. If I want to return ONLY the inactive
I have the following xml - <Surveys xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=ImmForm XML Schema NHS Direct.xsd><Svy SurveyName=WeeklyFluSurveillance2012/13-NHSDirectWeek40w/e07/10/2012

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.