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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:30:15+00:00 2026-05-18T06:30:15+00:00

Likely a remedial question, but in all my days as a PHP user I

  • 0

Likely a remedial question, but in all my days as a PHP user I have yet to encounter an answer. Basically, is there any way to grab a single field of a “mysql_query” as an array? For instance say I have the following:

$query = "Select id,first_name,last_name FROM people";
$result = mysql_query($query);

Is there any way to grab each (id, first_name, last_name) as individual arrays without iterating through the recordset? Can I say something like:

$ids = field_to_array($result['id']);
$first_names = field_to_array($result['first_name']);
$last_names = field_to_array($result['last_name']);

As I said, in the past I’ve always simply built the arrays as needed, but an existing method would be handy.

  • 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-18T06:30:16+00:00Added an answer on May 18, 2026 at 6:30 am

    mysql doesn’t have that as a native function. you could always write your own..

    function mysql_convert_cols($dataset) {
        foreach ($dataset as $row => $values) {
            foreach ($values as $column => $value) {
                $return[$$column][$row] = $value;
            }
        }
        return($return);
    }
    
    $resultConverted = mysql_convert_cols($result);
    $id=$resultConverted['id'];
    $firstName=$resultConverted['firstName'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Likely a dumb question but.. Are there any good guidelines for how much memory
,This question is likely subjective, but a lot of grid Javascript plugins have come
This is likely a novice question about LINQ, but assuming I have a set
This is likely a very simple question with a straightforward answer but I'm something
Most likely it's a dumb question for those who knows the answer, but I'm
Very likely a rather trivial question, but I simply couldn't find an appropriate answer.
This strikes me as likely to have an agreed best-practice answer, but I can't
I realise the answer is very likely to be 'no'! Basically, I have a
This is likely a duplicate of the below question but the only answer is
Another likely easy answer, but if I have a data structure called x.y that

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.