I need this script to print the id field one per iteration no all row by iterations help
<p>I don't know how to set up that the id field to print one by one per row in the script below which works wonders.    </p>

<pre><code>$tree = array();
 $sql = "select * from products
     left join product_varieties on product_varieties.product_id = products.id";
 $sth = query($sql);
 while($row = fetch($sth)) {
    $id = $row['id'];
    $tree[$id]['name'] = $row['name'];
    if($row['variety'])
       $tree[$id]['varieties'][] = $row;
 }

foreach($tree as $product)
    &lt;div&gt;
    echo $product['name']
    foreach($product['varieties'] as $variety)
         etc etc
    &lt;/div&gt;
</code></pre>

<p>I have been trying to use the id generated in the while loop inside the form action url string inside the foreach parent as you use the name index in the partent foreach. I have tried echoing and printing some how it won't display the id or if I print it, then it will appear three rows of ids per rows like 111333444555, I just want to be able to have the id per row like echo $product['name'] does, each iteration only prints one row of the index [ 'name'].</p>

<p>The form below won't echo anything, and I I change it to print then it will print 111222333444 help..</p>

<pre><code> foreach($tree as $product){
 &lt;form action="cart.php?id="'. echo $product['id']. '"&gt;
&lt;/form&gt; 
&lt;div&gt; echo $product['name'] echo $procude['id']
 foreach($product['varieties'] as $variety) {
etc etc 
&lt;/div&gt; 
}
}
</code></pre>
