tags:

views:

30

answers:

1

Hey ..

Im trying to list all added products from my session['cart'] and implode them, I just don't know how to list the implode, please help!

      $list = '';
  foreach($_SESSION['cart'] AS $key => $qyt){
   $items[] = array('size_id' => $qyt['size']);
  }

  $res = $db->Execute("SELECT s.name, p.item_num, p.name AS product_name, p.discount,
         s.price AS product_price,s.units

        FROM products_sizes s 
        INNER JOIN products p ON p.product_id = s.product_id
         WHERE s.id IN (". implode(",",  /* LIST SIZES_ID HERE */ ) .")
        ORDER BY s.id DESC
  ");
  while($row = $res->GetNext()){
+1  A: 

For the example given, two simple changes will suffice:

            foreach($_SESSION['cart'] AS $key => $qyt){
                    $items[] = $qyt['size'];
            }

            $res = $db->Execute("SELECT s.name, p.item_num, p.name AS product_name, p.discount,
                                                                    s.price AS product_price,s.units

                                                     FROM products_sizes s 
                                                     INNER JOIN products p ON p.product_id = s.product_id
                                                     WHERE s.id IN (". implode(",", $items) .")
                                                     ORDER BY s.id DESC
            ");
            while($row = $res->GetNext()){
Frank Farmer
thx it work perfect :)
william