I can think of a couple of ways to tackle this:

1) The purest way is to do with your database design - a typical order
processing database will contain a table for products, a table for
customers, a table for orders, a table for order lines and so on ... If this
is implemented correctly (ie the tables are correct) you should be able to
do an grouping and aggregate type query on the order line table that will
return the number of any particular product sold and from there you can
apply the correct price. You'll need to understand relational database
design to do this yourself (a v good topic to know if you're doing much in
the way of database backed sites anyway). The O'Reilly Book Web Database
Design with Php and MySQL uses a wine order processing application as a
running example throughout (although this appears to be principally about
using Php with MySQL rather than database design itself it may be worth
checking out)

2) More along the lines of your suggestion below you can use the MySQL '+'
operator .Every time you sell an item you can run an update query which goes
something like:-
UPDATE table_name SET num_of_items_sold_field= (num_of_items_sold_field + 1)
WHERE product_id_field = the_product_id
You can then use the value in 'num_of_items_sold_field' to determine product
price.


You may want to check out the MySQL list as the issue appears to be
principally a database rather than a php one.

If at all possible I would advocate the first approach - a properly designed
database will generally always pay divis in the long run.

Hope that this helps.
David Eisenhart


"Spiderwebb" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> From: "SpiderWebb" <[EMAIL PROTECTED]>
> Subject: Help nedded
> Date: 09 December 2002 16:46
>
> 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
>
> Thanks in advance.
> Spiderwebb
>
>
>
>







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

Reply via email to