how would I do this...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ee99ee
Forum Newbie
Posts: 9
Joined: Mon Mar 03, 2003 6:45 pm
Location: TN, USA
Contact:

how would I do this...

Post 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
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post 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);
ee99ee
Forum Newbie
Posts: 9
Joined: Mon Mar 03, 2003 6:45 pm
Location: TN, USA
Contact:

Post 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
Post Reply