The problem is that in your first foreach
loop you are just overwriting the $message
variable and the last product name is passed to the second loop.
Try this
echo "<html><head><title></title></head> <body> <table>";
for($i=0 ; $i < count($product) ; $i++)
{
echo "<tr><td>".$product[$i]."</td>";
echo "<td>".$quantity[$i]."</td></tr>";
}
echo "</table></body></html>";