this is untested. the deal is to go through each name in the array, select
everything from the table where the field name is equal to the name you have
from your array. if the number of rows pulled isn't zero, the name is already
there. if it is zero, the name is not in the db, so you do the insert....
pg_connect("", "", "", "", databasename);
while(list($key, $value) = each($name_array))
{
$result = pg_exec($db, "select * from tbl_foo where name='$value');
if(pg_numrows($result) == 0)
@pg_exec($db, "insert into tbl_foo (name) values ('$value')");
}