You might be making it more difficult than it needs to me.  You're not
dealing with a huge number of queries here so why not just loop it?  I would
simply loop through the $_SESSION array and query the dbase for each item.

foreach ($_SESSION as $key => $val)
    $query = "SELECT * FROM inventory WHERE itemnumber = '$val'";
    $result = mysql_query($query, $db);
    // .. blah blah blah...


----- Original Message -----
From: "Anup" <[EMAIL PROTECTED]>
Sent: Thursday, July 25, 2002 12:51 PM
Subject: [PHP] mySQL Queries using PHP's SESSION variables

> Hello, I am stuck here. In the name of efficiency I want to lower the
> 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
> has in his cart.
> eg. : I want something like this:
> $result = mysql_query("SELECT * from Inventory where ItemNumber is in
> //  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
> 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.
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to