>Hello, I am stuck here. In the name of efficiency I want to lower the number
>of callls to the database. So I am trying to give the most stringent query
>possible. This is the problem: I have stored the surfers shopping cart,
>where each item is stored as a session variable.Now on the database I have
>ALL inventory items, but I want to only display the details of what the user
>has in his cart.
>eg. : I want something like this:
>
>$result = mysql_query("SELECT * from Inventory where ItemNumber is in
>$HTTP_SESSION_VARS");
>//  I need proper syntax to replace "is in"
>
>where Inventory has, ItemNumber (unique), Price, ItemName.
>So say the surfer has three items in the Session, then I stored the three
>unique ItemNumbers.
>Then with the above query I can get the rest of the information to represent
>to the user.
>I am looking down the avenues of a Set datastyp or maybe Enum, but I don't
>know if it will help.


create table cart(
  session_id char(32),
  item_id int
);

Then, if I have item #42, #57, and #314, there will be 3 rows in this table
for me:

adsfqweradfzxcvasdfqwer 42
adsfqweradfzxcvasdfqwer 57
adsfqweradfzxcvasdfqwer 314

So you can just:

select item_id from cart where session_id = $PHPSESSID

-- 
Like Music?  http://l-i-e.com/artists.htm
I'm looking for a PRO QUALITY two-input sound card supported by Linux (any
major distro).  Need to record live events (mixed already) to stereo
CD-quality.  Soundcard Recommendations?
Software to handle the recording? Don't need fancy mixer stuff.  Zero (0)
post-production time.  Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo
audio-to-disk.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to