Page 1 of 1

how would I do this...

Posted: Thu Mar 13, 2003 10:35 pm
by ee99ee
I've got 3 tables. One table has all the inventory (each entry has an ID). Another table has all my customers (each customer has an ID). The third table has all my orders in it (each order has an order ID, a customer ID the order goes with, and the product ID of the product the order represents).

I've got it submitting orders just fine, but I want to pull this information and put it in an array (in which PHP wil then format it into an HTML table).

What I need in this array is this:

orders.ticketnum, orders.id, customers.id, customers.firstname, customers.lastname, product.size, product.style, product.pdate

How would one go about doing this? A left join? How? I group by customers.id.

-ee99ee

Posted: Fri Mar 14, 2003 12:39 am
by bionicdonkey

Code: Select all

$query = "SELECT orders.ticketnum, orders.id, customers.id, 
customers.firstname, customers.lastname, product.size, product.style, product.pdate FROM orders, customers, product GROUP BY customers.id";
$result = mysql_query($query, $dblink) or die(mysql_error());
$array = mysql_fetch_array($result);

Posted: Fri Mar 14, 2003 9:01 am
by ee99ee
Okay that's not what I ment. Sorry I know I wasn't very clear, it was late at night hehe.

But anyway, let's say customer 4 places an order for product id 6 with ticketid 5566 (ticketid is the ticket number on the actual order slip). When I go to run this script, it should pull:

-- orderid for this order
-- ticketid for the order
-- customers.firstname that corrosponds to the customer's id that's in orders.customerid for this order
-- customers.lastname that corrosponds to the customer's id that's in orders.customerid for this order
-- product.size that corrosponds to product.productid that's in orders.productid
-- product.style that corrosponds to product.productid that's in orders.productid
-- orders.pdate that is valid for this order

That make sence? I'd use a left join for that I think wouldn't I? How would I do this?

I guess this should be moved to the SQL forum, so if an admin sees this, would you please move it. Sorry for putting it in the wrong place...

-ee99ee