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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:22:25+00:00 2026-06-18T23:22:25+00:00

I have a orders table with the following columns: -userid -orderid (primary key) -date

  • 0

I have a orders table with the following columns:

-userid
-orderid (primary key)
-date
-name
-qty

So I would like to display in tables in a summary page all orders and group them under each userid. So it would be like

Userid: 0001
| Orderid | Name   | QTY |
|  1001   | Item A | 10  |
|  1002   | Item B | 5   |

Userid: 0003
| Orderid | Name   | QTY |
|  1003   | Item C | 6   |
|  1004   | Item C | 7   |

So far I’ve experimented and got:

  1. display in a single table all the items ordered by userid
  2. with a GROUP BY userid, I’ve managed to create as many tables as there are different userid

But I can’t seem to combine the two into the desired results and would really appreciate some advice on what I am doing wrong.

Thanks in advance and I hope my explanation made sense!

  • 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-18T23:22:26+00:00Added an answer on June 18, 2026 at 11:22 pm

    I think you will need to do this in PHP

    Query with

    select * from orders order by userid, orderid
    

    In PHP something like this psudo code

    $this_user_id=0;
    
    for (each order line)
    {
    get fields from db result;
    if ($this_user_id!=$userid)
    {
    $this_user_id=$orderid// save change of userid flag
    print user heading;
    }
    
    print order lines;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table 'tickets' with the following columns id - primary key -
I have a table department with the following columns. Id (P.K.) Name ParentDepartmentId (F.K.
Let's say I have a table with the following columns: p_id userid points Let's
I have a Sales table, with the following columns: employeeID amount date Now I
Let's say I have the following table: Orders ====== OrderID CustomerID StatusID DateCreated And
I have a table with the following columns: user_id, key, value, and flag. The
I have an orders table with a schema like this. CREATE TABLE orders (
If I have a table Orders with fields CustomerID , OrderID and OrderDate ,
I have 2 tables. For simplicities sake 'u' has the following columns userid divisionid
I have 2 tables: The question table with the following structure: id title userid

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.