this is more of a 'can you point me in the right direction' type of question.
Basically I would like to offer customers a way to 'save' their shopping cart, perhaps to view later with开发者_C百科 a relative (it's a 'photo basket' for a photographers clients).
When my 'photo basket' is used, it creates a single basket array
that is then filled with item arrays
.
My idea was --- create a table for each user and then implode
each array in the $_SESSION['basket']
to a string
and then add this string to a row in the DB. When the user logs back in, their saved basket can then be exploded from the database to form a new basket...
That's my chain of thought (not started this section yet). Just wondered if anyone could spot any obvious flaws and errors I might encounter.
Thanks for any input.
Shane
Don't create a table for each user. You can create a single table with a userid and datavalue columns, and save all users' baskets in the one table. Nor do you want to implode... use serialize on the $_SESSION['basket'] before storing it on the database, and unserialize when reading it back from the database
as mention before, don't create table, create a row. There are few php carts that do that (cs-cart). However, delete old baskets from the table after a while...
精彩评论