Обсуждение: pg_result
I have looked all over the site and I can not find good description for
'pg_result' I am having this problem. My database and everthing is
working fine but when I try to run a query from an html webpage it is not
working and I believe it is my 'pg_result' command. I have a table with
5-6 columns of information and I want total records to be selected. I then
reference the call to a variable and call it further in my HTML, but
nothing prints up. I have tried naming all the fields where 'row1' is
below but it also doesn't work. I am not getting any errors and html
prints back except for any values for '$rows', not even the row1 values
will come back. My query command works fine in psql.
Does anyone see my problem?
$result = pg_Exec($conn, "$query");
if (!$result);
echo "An error occured inserting information into our database.\n";
exit;
else;
pg_close ($conn);
endif;
$rows = pg_result($result,0,"row1");
Thanks in advance,
Dave
Dave,
>
> $result = pg_Exec($conn, "$query");
> if (!$result);
> echo "An error occured inserting information into our
> database.\n";
> exit;
> else;
> pg_close ($conn);
> endif;
> $rows = pg_result($result,0,"row1");
>
(Assuming you're using php3)
I think something like this is what you're looking for:
$conn = pg_Connect("localhost", "5432", "", "", "efakt");
if (!$conn) {
echo "Cannot connect to PostgreSQL database.\n";
exit;
}
$result = pg_Exec($conn, "set datestyle='ISO';
select * from invoices
where seqid = $invid");
if (!$result) {
echo "Faktuur niet gevonden! ($resinv $invid)\n";
exit;
}
$num = pg_NumRows($result);
$i = 0;
while ($i < $num) {
echo pg_Result($result, $i, "invoiceno");
$i++;
}
pg_FreeResult($result);
pg_Close($conn);
Rob den Boer