PHP Checkbox Values
<p>I'm trying to create a checkout page in PHP. The page that lists the items is called shop.php. On this page, I display a number items to be sold with a checkbox beside each item. I'm pulling the item name and price information from the database. Here's my main code. </p>

<pre><code>$row = mysql_fetch_array($query);
while($row) {
     echo "&lt;TR&gt;";
     echo "&lt;TD&gt;&lt;B&gt;$row[Name] &lt;/B&gt;&lt;/TD&gt;";
     echo "&lt;TD&gt;&lt;B&gt;"."$"."$row[Price] &lt;/B&gt;&lt;/TD&gt;";
     echo "&lt;TD&gt;&lt;input type=checkbox name=foods[] value='$row[Price]' /&gt;&lt;/TD&gt;";
         echo "&lt;/TR&gt;";
$row = mysql_fetch_array($query);
}

&lt;input type="submit" name="buy" value="Buy Now" /&gt;
</code></pre>

<p>So I am setting the name of the checkboxes to foods[] which'll be an array that'll contain values of all checkboxes submitted. When the user clicks on the "Buy Now" button, they'll be redicted to the cart.php page, that'll display the name and price of the item they've purchased. I know that I can output the prices by looping through the $items array. The problem I have is that I don't understand how would I display the item names. I thoght of doing the following:</p>

<pre><code> $row = mysql_fetch_array($query);
 while($row) {
   echo "&lt;TR&gt;";
   echo "&lt;TD&gt;&lt;B&gt;$row[Name] &lt;/B&gt;&lt;/TD&gt;";
   echo "&lt;TD&gt;&lt;B&gt;"."$"."$row[Price] &lt;/B&gt;&lt;/TD&gt;";
   echo "&lt;TD&gt;&lt;input type=checkbox name='$row[Name]' value='$row[Price]' /&gt;&lt;/TD&gt;";
    echo "&lt;/TR&gt;";
$row = mysql_fetch_array($query);
}
</code></pre>

<p></p>

<p>This time, both the name and the price of the items are included in the checkbox as its name and value. But again, the problem is how would I display them on the cart.php page without hard coding. What I means is that how would I display the item name and its price without doing something like this: </p>

<p>(Assume that one of the items name is Burger which was populated as the name of the checkbox.)</p>

<pre><code>if (isset($_POST['Burger'])){
echo "&lt;td&gt;$_POST['Burger']&lt;/td&gt;";
}
</code></pre>

<p>I'd appreciate any suggestions/tips on this question. Thank you.</p>
