# Shopping cart - Dropdown menu problem please help

**URL:** <https://forum.kirupa.com/t/shopping-cart-dropdown-menu-problem-please-help/198707>\
**Category:** programming\
**Created:** [August 28, 2006, 1:35am UTC](https://forum.kirupa.com/t/shopping-cart-dropdown-menu-problem-please-help/198707 "2006-08-28T01:35:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paxdev](https://avatars.discourse-cdn.com/v4/letter/p/6a8cbe/32.png) [@paxdev](https://forum.kirupa.com/u/paxdev)\
**Post date:** [August 28, 2006, 1:35am UTC](https://forum.kirupa.com/t/shopping-cart-dropdown-menu-problem-please-help/198707/1 "2006-08-28T01:35:08Z")

</div>

Hi,  
I’m new to PHP and trying to build a shopping cart. I’m displaying all the items in 1 page as several rows. Each product is of different sizes and prices.  
So i have 2 tables, One with product name and the other table with product size and prices.

I want to display each product name and a dropdown with the weight and prices of for that size.  
I researched the internet and did some coding.  
I’m able to write each in a row with a dropdown of the sizes, but the problem is the dropdown is writing the values several times for the iteration and hence my dropdown has the same values 6 times the number of rows in the product table.

```php
 
<?php
 // This page will list all of the items
 // from the items table. Each item will have
 // a link to add it to the cart
 include("db.php");
 
 // Get a connection to the database
 $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
 $result = mysql_query("select * from items order by itemName asc");
?>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="34%" height="25">
<font face="verdana" size="1" color="black">

<?php echo $row["itemName"]; ?> </font> </td>
       
<td width="17%" height="25">
<label><font face="verdana" size="1" color="black">

<?php
$sql = 'SELECT * FROM prodsize';
  $res = mysql_query($sql) or die(mysql_error());
  while ($rec = mysql_fetch_assoc($res)) $prices[] = $rec;
  // die('<pre>'.print_r($countries));
  echo '<SELECT name="dropdown">';
  reset($prices);
  foreach ($prices as $c)
  {
    if ($c['id'] == $_GET['id'])
      echo "<OPTION value=\"{$c['prodid']}\" SELECTED>{$c['prodwt']}, {$c['prodprice']}</OPTION>
";
    else
      echo "<OPTION value=\"{$c['prodid']}\">{$c['prodwt']}, {$c['prodprice']}</OPTION>
";
  }
  echo '</SELECT>';
 
                           
   

}
   
?>
 

```
