Re: Multiple Table Selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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?



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux