Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

FN-FORUM: Help/guidance with a bit of tricky php/MySQL

date posted 4th March 2008 11:36

Morning all!

Hoping someone can help out with this - a little tricky!

The background:
I have an online shop, which has products (eg car) and product
variants (eg red car, blue car, etc...). Some products have variants,
and some products don't.
When an order is placed I have an Orders table which stores the userid
of customer ordering, order date, etc.. Then, for each product without
variant, and for each product variant, I add an entry to Order_items
which stores the productid (if product doesn't have variant), or
productid AND variant (if it does), along with the quantity for that
order.

What I want to do:
Be able to generate a report of the top 10,20, or x products or
product variants which are selling.

How to do it:
The lame way of doing it would be to go through the products and (if
applicable) their variants, and for each, querying Order_items,
returning all the entries, and totalling up their quantity fields, and
storing this into somekind of array. I am not very good with joins,
which I am guessing may also be needed. I can think of doing this
otherwise by storing the results in a table, but with over 4,000
orders and 18,000 order items, I need to be thinking about a very
efficient algorithm.

Over to you, anyone with any ideas to point me in the right direction?

Many thanks,

Duncan



Messages by Day
March 31st 2008
March 30th 2008
March 29th 2008
March 28th 2008
March 27th 2008
March 26th 2008
March 25th 2008
March 24th 2008
March 23rd 2008
March 22nd 2008
March 21st 2008
March 20th 2008
March 19th 2008
March 18th 2008
March 17th 2008
March 16th 2008
March 15th 2008
March 14th 2008
March 13th 2008
March 12th 2008
March 11th 2008
March 10th 2008
March 9th 2008
March 8th 2008
March 7th 2008
March 6th 2008
March 5th 2008
March 4th 2008
March 3rd 2008
March 2nd 2008
March 1st 2008


Messages by Month
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000