The form lists 50 products from the database. I get the name of the product and the variable name for the field for that product from the database. The user can decide how many of each product they wish by entering a number into the quantity text box provided.
After hitting submit they are taken to a new page that tells them that an email has been sent with the information to the appropriate department as well as displaying their selections for them to print off.
My question is how do I get the name of each product and the quantity of each product selected into the message part of the email? At the moment I only get the last product in the array.
This is the code I'm using to loop through the separate products from the form.
foreach($_POST as $key => $val)
{
if ($val != '')
{
$sql = " SELECT product_title, product_item
FROM products
WHERE product_vname='".$key."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
extract($row);
echo "
<tr>
<td><p>".$val."</p></td>
<td align=left valign=top><p>".$product_title." ".$product_item."</p></td>
</tr>";
}
mysql_free_result ($result);
}
}
I'm really stuck on this one. Thanks for any help.