Here is another way to iterate a resultset and display all columns in very little code... might be faster than a foreach
<?php
print '<table>';
while($row=pg_fetch_assoc($rs2)) print '<tr><td>'.join('</td><td>',$row2).'</td></tr>';
print '</table>';
?>