toe_head2001
04-05-2009, 07:24 PM
If have and array called food (generated by form checkboxes) in which each items in that array is in its own mysql database row with another entry called price. I would like to create a second array for the prices.
I have written this code to display each price of all the item in my food array.
Having them list is fine, but I would like them to be in an array so I can easily add them up. How can I change it so it will put all the prices into an array.
foreach($food as $foodarray) {
$result = mysql_query("SELECT * FROM menu WHERE name='".$foodarray."'");
while($row = mysql_fetch_array($result))
{
echo $row['price'], " ";
}
}
Thanks.
I have written this code to display each price of all the item in my food array.
Having them list is fine, but I would like them to be in an array so I can easily add them up. How can I change it so it will put all the prices into an array.
foreach($food as $foodarray) {
$result = mysql_query("SELECT * FROM menu WHERE name='".$foodarray."'");
while($row = mysql_fetch_array($result))
{
echo $row['price'], " ";
}
}
Thanks.