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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:23:17+00:00 2026-06-08T03:23:17+00:00

After several attempts to find a unique solution for my thought, I’ve had no

  • 0

After several attempts to find a unique solution for my thought, I’ve had no chances to post this question here in the hope to find someone who can enlight me (if applicable).

I’m working on a “full featured” PHP class with several methods so I will be able to do what I’m willing to do in the future (that is, kinda of personal framework).

I’m stuck in the fetchRow() method of the class. I would like to use this method to fetch rows from a query AND I would like that this method automatically forms the proper data structure.

Now, assuming that I have a query like:

$query = mysql_query("SELECT name, surname FROM people", $dbHandle);

I would like to have this result (if applicable):

/*
 * var_dump example results after launching a while statement with
 * mysql_fetch_row.
 *
 * 2 fields (name,surname), 2 "master" arrays with corresponding values
 *
 */

array
 0 = array( ...names... )
 1 = array( ...surnames... )

Now, I tried several native PHP functions, user-defined functions, etc, without goals.

Maybe I’m crazy after these attempts, maybe this is not possible or maybe I can’t see a possible simple way to do that.

How can I do that?

  • 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-08T03:23:20+00:00Added an answer on June 8, 2026 at 3:23 am

    Well you would just do something like:

    $data = array();
    while (false !== ($row = mysql_fetch_array($result, MYSQL_NUM)) {
       foreach($row as $key => $value) {
          if(!isset($data[$key]) {
             $data[$key] = array();
          }
    
          $data[$key][] = $value;
       }
    }
    

    That said…

    1. Just use Doctrine – either the full ORM or the DBAL.
    2. Dont use ext/mysql use PDO or Mysqli.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a class that only worked in Delphi 7 and after several attempts
after several attempts, I can not solve this problem. I have the following mysql
After looking at several questions/answers here, I'm not seeing what I think I need.
I'm trying to implement the Sieve of Eratosthene in C++. However after several attempts
Great page this one, coming from the perl world and after several years of
After several failed attempts using ExtJS I have now decided to use javascript.The requirement
After several attempts to change the background of a button, and getting errors of
so i have made several attempts at this, but decided i needed some advice
I am a little confused, and after countless attempts and read several articles I
After several unsuccessful attempts to use JXTA api, i have decided to roll out

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.