Jump to content

Simple PHP mySQL query


frank5050

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.