pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Multiple Table Selection
2+ messages / 2 participants
[nested] [flat]

* Multiple Table Selection
@ 2002-06-10 07:26  arun kv <arun@library.iisc.ernet.in>
  0 siblings, 1 reply; 2+ messages in thread

From: arun kv @ 2002-06-10 07:26 UTC (permalink / raw)
  To: pgsql-php

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Multiple Table Selection
@ 2002-06-10 09:25  Andrew McMillan <andrew@catalyst.net.nz>
  parent: arun kv <arun@library.iisc.ernet.in>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrew McMillan @ 2002-06-10 09:25 UTC (permalink / raw)
  To: arun kv <arun@library.iisc.ernet.in>; +Cc: pgsql-php

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 "<p> 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 "<table>";
  for( $i = 0; $i < pg_NumRows($result) ; $i ++ ) {
    $row = pg_Fetch_Object( $result, $i );
    echo "<tr><td>$row->field1</td><td>$row->field2</td></tr>\n";
  }
  echo "</table>";
}
else {
  echo "<p> 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?




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-06-10 09:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-10 07:26 Multiple Table Selection arun kv <arun@library.iisc.ernet.in>
2002-06-10 09:25 ` Andrew McMillan <andrew@catalyst.net.nz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox