RE: [PHP-GENERAL] PHP4
| From: | Chris Davis | Date: | Tue, 30 May 2000 13:20:57 +0000 |
| Subject: | RE: [PHP-GENERAL] PHP4 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-624@lists.php.net to get a copy of this message | ||
Typical me, if I can over complicate something I will. I think you may have
just brought me on leaps and bounds in just a couple of sentences, cheers
James.
-----Original Message-----
From: James Lyon [mailto:james.lyon@aztec.co.uk]
Sent: 30 May 2000 14:06
To: Chris Davis
Cc: Php Mailing Ist (E-mail)
Subject: Re: [PHP-GENERAL] PHP4
> 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?