Jump to content

Recommended Posts

Hello guys,

 

I have 2 tables in my mySQL database.

 

One table stores the customer info and the other table stores the products they ordered.

 

"Order_ID" is the common variable in both tables.

 

I have written a join query which pulls data from both tables.

 

My query looks like this:

 

$query = "SELECT c.*, p.Product_SKU from csm c, csmproducts p where c.Order_ID = p.Order_ID and c.Order_Status='Awaiting Fulfillment' group by Order_ID order by Order_ID DESC LIMIT $startrow, 50";

$numresults=mysql_query($query);

$numrows=mysql_num_rows($numresults);

}

 

The trouble I am having is that I can query the database for a particular Order_ID, but if that Order_ID has multiple products in it , only the first product is showing. What do I need to do such that where {$row['Product_SKU']} gives me only the first product, I can pull all the Product_SKUs for that particular Order_ID.

 

Currently the output looks like this (showing just the first item the customer orderd)

Order ID:                      Product SKU

5558                            DSC-3433

 

I would like to see it like this:

 

Order ID:                      Product SKU

5558                              DSC-3433

                                      ASD-6454

                                      UFY-7383

5559 ...................... on and on  and on for next orders

 

Thanks in advance for the assistance.

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/229093-simple-php-mysql-query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.