Re: Help needed

From: Date: Tue, 10 Dec 2002 23:50:06 +0000
Subject: Re: Help needed
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-24047@lists.php.net to get a copy of this message
"Spiderwebb" <spiderwebb@ec-sys.com> wrote in message news:20021209154609.74848.qmail@pb1.pair.com... > 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?

« previous php.db (#24047) next »