<?php

$conn = pg_pconnect("dbname=jaime user=postgres password=postgres port=5433");
$name = $_POST['name'];
$temp = 'c:/xampp/htdocs/pgimagen/imagenes/tmp.jpg';

$query = "select lo_export(image, '$temp') from image where name = '$name'";
echo $query;
$result = pg_query($query);

if($result)
{
	$query = "select * from image where name = '$name'";
    $result = pg_query($query);
    while ($line = pg_fetch_array($result))
    {
        $ctobj = $line["image"];
        echo "<IMG SRC=show.php>";
        printf ("<br/>".$line["name"]." - ".$line["day"]." ");
    }

}
else { echo "File does not exists."; }
pg_close($conn);

?>