Re: PHP4
| From: | James Lyon | Date: | Tue, 30 May 2000 13:05:34 +0000 |
| Subject: | Re: PHP4 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-623@lists.php.net to get a copy of this message | ||
> Can you desribe how you do that, thats quite an interesting idea ... it
> might suit my needs better!
>
> Any advice would be appreciated.
For example a shopping basket ... very common problem.
I have a database table "basket" that has a record for each basket, with a
unique integer keyfield -- the basket ID.
I also have a basketcontent table, linked one-to-many with the main "basket"
table. (You okay with relational databases?)
Then, when the user first arrives in my shop I add a record to my "basket"
table, giving them a new unique ID -- doesn't matter if it's never used. I also
note an expiry time so I can delete old baskets later if I want. I happen to use
a cookie to store the basket number on the user's machine, but you could pass it
from script to script using GET variables etc.
Then, anything I want to record that relates to the basket of the current user I
do by storing it against their unique ID in my MySQL table. I can retrieve it
any time, the id is unique to the user and doesn't depend on addresses or
anything like that.
Does that explain the kind of thing I mean?