that code only needs to go on line 1 of the page you added the add to cart button to:
Foodproducts_Results.php
See the following post for details on the headers already sent error:
showthread.php?t=19285
if you need further assistance, I will need a copy of the Foodproducts_Results.php page.