Jump to content

matthew798

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by matthew798

  1. Hi guys! Once again i require your endless talents! I have 2 tables in my mysql DB. One table is a list of products a store offers, the other is the cart of the user. I need to find the most efficient way or retrieving the images and prices from the LIST OF PRODUCTS table based on the list of PRODUCT NUMBERS stored in the cart table of the user. List of products offered ************************* Prod # * Price * img src * ************************* 001 * 19.99* imgs/pic1.jpg * 002 * 29.99 * imgs/pic2.jpg * ************************* User's Cart ********************* Prod # * quantity * size * ********************* 001 * 10 * m * 002 * 4 * s * ******************** Basically i just want to retrieve ONLY the rows that i need (ones that the user has added to his/her cart) and ASSOCIATE the img src with the quantity and size so that i can lay it out in a table on a view_cart page... If you want a good laugh just take a look at what ive done so far... $cart = mysql_query("SELECT * FROM ".$session.""); $cart_row_count = mysql_fetch_assoc($cart); $cart_row_count = mysql_num_rows($cart_row_count); if($cart_row_count != 0){ $i = 1; while($cart_result = mysql_fetch_assoc($cart)){ ${"product$i"} = $cart_result['product']; ${"size$i"} = $cart_result['size']; $i++; } $i2 = 1; $query = "product = ".${"$product$i2"}." "; while($i2 <= $i){ $i2++; $query .= "AND ".${"$product$i2"}." "; } }
  2. Hey all, Im just wondering what the best way to store a bunch of products numbers under a session id. I have a shopping cart that i want people to be able to add products to it. The product id numbers are around 4 digits each. Im just wondering what the most efficient way to store the cart is. Create an individual table for each session ID and store the products there? Create a table that stores each session ID and add the products in the same collumn then separae them when needed? I cant think of any efficient sounding way to do this. Heres some more info: session_id = 0000001 (for example) **************************** * SESS * PRODUCTS * **************************** *0000001* 1001,1002,1003,1004* **************************** Thats what im thinking of doing now, but im worried about how im going to store carts that have 20 or more products, 20*4+20 commas, im looking at 100+ characters in one collumn... I dunno... What do you guys think?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.