pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew McMillan <andrew@catalyst.net.nz>
To: arun kv <arun@library.iisc.ernet.in>
Cc: PGSQL <pgsql-php@postgresql.org>
Subject: Re: Multiple Table Selection
Date: 10 Jun 2002 21:25:56 +1200
Message-ID: <1023701156.4952.72.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <Pine.BSO.4.44.0206101247300.17659-100000@library.iisc.ernet.in>
References: <Pine.BSO.4.44.0206101247300.17659-100000@library.iisc.ernet.in>

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?




view thread (2+ messages)

Message-ID: <1023701156.4952.72.camel@kant.mcmillan.net.nz>
Permalink:  ../1023701156.4952.72.camel@kant.mcmillan.net.nz/
Also on:    postgresql.org/message-id/1023701156.4952.72.camel@kant.mcmillan.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: andrew@catalyst.net.nz, arun@library.iisc.ernet.in
  Subject: Re: Multiple Table Selection
  In-Reply-To: <1023701156.4952.72.camel@kant.mcmillan.net.nz>
  References: <Pine.BSO.4.44.0206101247300.17659-100000@library.iisc.ernet.in> <1023701156.4952.72.camel@kant.mcmillan.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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