I use the following code for importing from a textfile into a table... basic code, no good writing (if you have comments, please mail)
$database = pg_connect(your_info_here);
$stockpriceinfo_csv = fopen("info.csv", "r");
while (!feof($stockpriceinfo_csv)) {
$koers = fgetcsv($stockpriceinfo_csv, 5000, ";");
// the 5000 above depends on the length of your fields
$price = $koers[2];
$code = $koers[0];
$name = $koers[1];
$price = ereg_replace (",", ".", $waarde); // replace , in the
// price (dutch notation) with "."
$naam = ereg_replace ("'", "''", $naam); // replace ' with double '
to prevent failure
pg_exec ($database, "insert into tablename (code, name, price)
values ('$code', '$name', '$price')");
}