Easiest and shortest way?

Andy <alewis@mpsi.net>

From: Andy Lewis <alewis@mpsi.net>
To: pgsql-general@postgreSQL.org
Date: 1998-10-15T19:22:52Z
Lists: pgsql-general
I am getting ready to write some PHP code that will involve the following:

[1] make a connection to a Postgres DB via PHP/Apache
[2] query a table for records. only get new records that we didn't get last
    query. guess I'll have to set some sort of flag.
[3] email the results to the requestor

My question is without reinventing the wheel, what the shortest code that I can
write.