How do i add information to a session of shopping cart data into a database?
-
i have a shopping cart and i wanted to store the shopping cart information to my database but i have no idea how to do it since i have no way to detect how many items my customer would add to their shopping cart. What i have in mind right now would be having a non-unique key as shopping cart id. I.E ID / book / price / quantity 1/harry potter/19.90/1 1/deadly hollows/49.90/1 and both of id 1 will consitute as a complete shopping cart. Will there be something wrong with this way of doing?
-
Answer:
A non-unique key is not a good solution. I would add an auto-increment key to the shopping cart table and use that as "real" unique key. Just keep your non-unique ID as it is, so you can use it as an OrderID to see which rows belong to the same order. Like this: UniqueID / OrderID / book / price / quantity 1/1/harry potter/19.90/1 2/1/deadly hollows/49.90/1 3/2/code complete/25.90/2
3cross at Stack Overflow Visit the source
Other answers
You should have a Primary Key that is unique, but can span multiple columns: You could probably use ID and book as your Primary Key, since each cart won't have 2 copies of the same book, because that would just update the quantity, not add a new row.
PaulP.R.O.
Related Q & A:
- How do I bind data to a ComboBox?Best solution by Stack Overflow
- How can I display data in a listview?Best solution by Stack Overflow
- How do I add information to my profile?Best solution by Yahoo! Answers
- How do I add graphics to a video?Best solution by Yahoo! Answers
- How do I add all my contacts from an old email address to a new email address on msn?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.