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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:03:38+00:00 2026-05-23T11:03:38+00:00

How do I get a SQL result that will contain multiple rows into an

  • 0

How do I get a SQL result that will contain multiple rows into an array:

Example SQL Table:

ID      Cat        LineID      Qty    DealID    Cost
1       Phone      1           2      8941      25.00
2       Phone      2           43     8941      85.00
3       Net        1           2      8941       1.00
4       App        1           1      8941      87.00
5       Phone      1           20     8942      98.00

Would like to be able to return the result like:

$product[Phone][LineID][Qty]
$product[Phone][1][Qty] -- this would return 2

BTW: Within a Cat the LineID would never be duplicated, but it may not alway be the same LineID’s – for Example under DealID 8941 there might be LineID for Cat>Phones 1,2,3,4 but under a different DealID there might only be Cat>Phones 4,5

Not sure if I’m barking up the complete wrong tree, basicly I need to loop through all the results under a DealID then cross reference the LineID to get all the information about that LineID from a another table which holds the name, image etc…Then put into a html table along the lines of:

Product Name     Qty     Cost     Line Total
Phone 1           1      85.00    85.00

I hope I have made this clear, if not don’t be too harsh!!

Thanks,
B.

  • 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-23T11:03:38+00:00Added an answer on May 23, 2026 at 11:03 am

    This is the answer:

    $sql="SELECT * FROM Blar";
    $result = mysql_query($sql);
    $combinedResults = array();
    while ($row = mysql_fetch_array($result)) {
        $combinedResults[$row['cat']][] = array( 
        'LineID' => $row['lineID'],
        'Qty' => $row['qty'],
        'SetCost' => $row['Setcost'],
        'MonCost' => $row['Moncost'],
        'Postcode' => $row['postcode']
        );
    };
    //print_r($combinedResults);
    print_r($combinedResults['Apps'][0]['Qty']);
    

    Thanks for your help @Dereleases

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

Sidebar

Related Questions

In a SQL-database I make some selects, that get an duration (as result of
I have a table that contains many rows of SQL commands that make up
I'm trying to get a query going that will search multiple tags. The tags
I am creating a product that as end result will/can create e.g. 10 .sql
I need to get only 1 record from sql result. we use SELECT TOP
I'm using LINQ to SQL to get a search result of a FullTextSearch stored
How can I get a SQL dump of a SQL Server 2008 database? That
Is there any way to use Dapper.NET with stored procs that return multiple result
I will have an sql table named VISIT table. I have 3 columns WORKSTATION,
I have a Manager class that saves data in the SQL table and also

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.