"Spiderwebb" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I dont know if this is possible in PHP (Newbie) im working on a project
> where each product has 3 diffierent prices depending on the amount sold so
> say for example 1- 100 price A 101-299 price B and above 300 Price C.
What
> I need to be able to do is increment an mysql database field each time an
> item is sold then look at that field to decide which price variable to
write
> to the price field of the database. Could someone point me in the right
> direction where I could solve this or to someone who could

First, how are you storing the price points?
I would consider a separate pricing table linked
to the item table like so:

    table ItemForSale
      id integer auto_increment
      name varchar(30)
      descr varchar(200)

    table PricePoint
      id integer auto_increment
      item integer
      ordersize integer
      priceper float

then for a given item and number of items ordered, you
can retrieve the applicable price-per by

SELECT priceper FROM PricePoint
 WHERE item=$itemID AND ordersize<=$number
 ORDER BY ordersize DESC
 LIMIT 1

Each item can have an arbitrary number of
price points at any number-of-items.  Note
that this assumes the priceper always decreases
with increasing ordersize for a given item.


Second, I don't understand why you reset
the cumulative price-point every time you
process an order; for selling, surely the price-
point only applies to a single order rather
than cumulatively, and for purchasing or
reporting, I would expect to calculate it
dynamically at the time the report is generated.
Have I missed something?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to