Disclaimer: This code is untested.
The problem with your foreach loop is that you are redefining $res before doing anything with it. There was also a problem with the WHERE clause in your database query.
In this case try using Implode.
<?php
$lsWhereClause = " WHERE (refcode='" . implode("' OR refcode='", $box) . "' ";
$res = pg_query ($conn, "select refcode, title, description, price from TopGames " . $lsWhereClause . ";")
?>
As for the rest of the code, it looks like you're going a little overboard with the brackets.
Try this:
<?php
echo '<form name="chec" action="cart.php" method="post">';
echo "<table border='1'>";
while ($laRow = pg_fetch_row($res))
{
echo "<tr>";
echo "<td>";
echo "<input type='checkbox' name='box[]' value='" . $laRow['refcode'] ."' />";
echo "</td>";
echo "</tr>";
}
?>