title: how to echo all products in shopping cart to paypal
body: <p>I am just learning the ropes of php and am building an e-commerce site for a uni project, I have the whole thing built and setup payment via paypal, which I've done through a few tutorials.</p>
  
  <p>When I am transferring to paypal I want to display; the item name, price and quantity for each item in the cart, within the order summary.</p>
  
  <p>In its current state <a href="http://pastie.org/3127790" rel="nofollow">http://pastie.org/3127790</a> , the code is only displaying the top item in the cart in the order summary on paypal, I think I need to implement a foreach loop to tell the code to echo all rows in the cart, but am unsure what exactly to loop and how.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Thanks in advance, Michael </p>
  
  <p>
  Code snippet</p>
  
  <pre><code>      &lt;?php
  
          $sql = "SELECT * FROM podcasts WHERE id_podcasts IN (";
            foreach ($_SESSION['cart'] as $id =&gt; $value){
              $sql .= $id . ",";  
            }
            $sql = substr($sql,0,-1).") ORDER BY name ASC";
            $query = mysql_query($sql);
            $total_price = 0;
            if(!empty($query)){
            while($row = mysql_fetch_array($query)){
              $subtotal = $_SESSION['cart'][$row['id_podcasts']]['quantity']*$row['price'];
              $total_price += $subtotal;
              ?&gt;
  
              &lt;?php
              $ppname = $row['name'];
              $_SESSION['cart'][$row['id_podcasts']]['name'] = $row['name'];
              $ppquantity = $_SESSION['cart'][$row['id_podcasts']]['quantity'];
              $ppprice= $row['price'];
              ?&gt;
                &lt;tr&gt;
                  &lt;td&gt;&lt;?php echo $row['name'];?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $_SESSION['cart'][$row['id_podcasts']]['quantity'];?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo "&amp;pound;" . $row['price'];?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo"&amp;pound;" .  $_SESSION['cart'][$row['id_podcasts']]['quantity']*$row['price'];?&gt;&lt;/td&gt;
                &lt;/tr&gt;
              &lt;?php
            } }
            ?&gt;
  
  
    &lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span&gt;Total Price:&lt;/td&gt;&lt;/span&gt;
      &lt;td&gt;&lt;span&gt;&lt;?php echo"&amp;pound;" .  $total_price;?&gt;&lt;/td&gt;&lt;/span&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"&gt;
  &lt;input type="hidden" name="cmd" value="_xclick"&gt;
  &lt;input type="hidden" name="business" value="payme_1321908135_biz@immbudden.com"&gt; &lt;!-- change to your paypal address --&gt;
  &lt;input type="hidden" name="quantity" value="&lt;?php echo $ppquantity;?&gt;"&gt; &lt;!-- do not change, since you refer to it all via the database --&gt;
  &lt;input type="hidden" name="item_name" value="&lt;?php echo $ppname;?&gt;"&gt;
  &lt;input type="hidden" name="amount" value="&lt;?php echo $ppprice;?&gt;"&gt; &lt;!-- change here --&gt;
  &lt;input type="hidden" name="shipping" value="0.00"&gt;
  &lt;input type="hidden" name="currency_code" value="GBP"&gt;
  &lt;input type="hidden" name="custom" value="&lt;?php echo $_SESSION['emailaddress'];?&gt;"&gt; &lt;!-- if you store their purchase in a database, reference the database number here --&gt;
  &lt;input type="hidden" name="return" value="http://shop.residencyradio.com/success.php"&gt;
  &lt;span class="input_btn"&gt;&lt;input type="submit" name="purchase" value="Purchase" &gt;&lt;/span&gt;
  &lt;/form&gt;
  </code></pre>