Multiple Table Selection
am 10.06.2002 09:26:20 von arun kv
hello sir,
I am having a postgresql database and using php to access the
same. i have three tables and my program has to search for the data
entered thru my php page in all these tables.
i have to enter either of name,age or company of a person and have to
search for either of these in all the three tables and display results.for
1 table its working fine but for 3 tables it gives me error: Unable to
jump to row 0 of postgresql result index 3 on *.php file. how can i
override this warning. i have to search all the tables if i enter 1 or 2
or all three values. how can i do the same.
can somebody help me in this problem.
Thanks in advance
With Regards
Arun
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Re: Multiple Table Selection
am 10.06.2002 11:25:56 von Andrew McMillan
On Mon, 2002-06-10 at 19:26, arun kv wrote:
> hello sir,
> I am having a postgresql database and using php to access the
> same. i have three tables and my program has to search for the data
> entered thru my php page in all these tables.
>
> i have to enter either of name,age or company of a person and have to
> search for either of these in all the three tables and display results.for
> 1 table its working fine but for 3 tables it gives me error: Unable to
> jump to row 0 of postgresql result index 3 on *.php file. how can i
> override this warning. i have to search all the tables if i enter 1 or 2
> or all three values. how can i do the same.
Usually that error means that the query executed fine - it just found no
records.
Test the value of pg_NumRows($result) to see if you need to process the
results, viz:
$result = pg_Exec( $dbconn, $sql );
if ( !$result ) {
echo "
Search failed";
// Security hole to tell the user the query is busted but we log it
error_log( "Broken query: $sql", 0);
}
elseif( pg_NumRows($result) ) {
echo "
";
for( $i = 0; $i < pg_NumRows($result) ; $i ++ ) {
$row = pg_Fetch_Object( $result, $i );
echo "$row->field1 | $row->field2 |
\n";
}
echo "
";
}
else {
echo " No Records Found";
}
Which is a simplification of how I wrap many of the queries I use (I put
most of this sort of logic in a standard function and just call that).
Regards,
Andrew.
--
------------------------------------------------------------ --------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Are you enrolled at http://schoolreunions.co.nz/ yet?
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org