Algorithm for finding a shopping cart
When the customer added to the shopping cart after purchase, how to get the total price of the goods, if the Apple unit price of 10 yuan A, banana 5 yuan A, dragon fruit 8 yuan A, bought 3 apples, bananas 2, dragon Fruit 5, the current database is so designed a table put ID, commodity name, Price, b table put ID (and the ID of a table corresponds to), the number of items purchased, how to get the last price (the simplest and most efficient way), my current method is to use a multi-table query to the customer under the purchase of all the data query, and then in PHP with a foreach loop array, and then multiply the price and number, Finally, the results are added and the efficiency is not good.
------Solution--------------------
The reply was deleted by the administrator in 2013-01-11 12:19:36