попробуйте этот код:
<?php
$db = pg_connect("host=localhost port=5432 dbname=your_db user=postgres password=your_paswrd");
//call excel reader
require "excel_reader.php";
//press button
if(isset($_POST['submit'])){
$target = basename($_FILES['fopenl']['name']) ;
move_uploaded_file($_FILES['fopenl']['tmp_name'], $target);
$data = new Spreadsheet_Excel_Reader($_FILES['fopenl']['name'],false);
//count row of excel xls
$baris = $data->rowcount($sheet_index=0);
//empty database before
$drop = isset( $_POST["drop"] ) ? $_POST["drop"] : 0 ;
if($drop == 1){
//empty employee table
$truncate ="TRUNCATE TABLE employee";
pgsql_query($truncate);
};
//import data from xls
for ($i=1; $i<=$baris; $i++)
{
//read from xls
$emp_id = $data->val($i, 1);
$date = $data->val($i, 2);
$id_mac = $data->val ($i, 3);
$val_a = $data->val($i, 4);
$val_b = $data->val($i, 5);
$stat = $data->val($i, 6);
$note = $data->val ($i, 7);
//setelah data dibaca, masukkan ke tabel dari_finger
$query_insert = "INSERT into employee (emp_id,date,id_mac,val_a,val_b,stat,note)values('$emp_id','$date','$id_mac','$val_a','$val_b','$stat','$note')";
//eksekusi query insert
$insert = pg_query($query_insert);
}
if(!$insert){
//jika import gagal
die(pgsql_error());
}else{
//jika impor berhasil
echo " Data imported,";
}