View Single Post
Old 04-07-2006, 12:36 PM   #1 (permalink)
tomycon
Recruit
 
Join Date: Jul 2002
Location: Massachusetts
Posts: 13
tomycon is on a distinguished road
using empty row to trigger if

Hello,

I'm trying to get an empty result from a postgresql query to trigger an "if" loop. More specific, I query the db for data on a specific item that if fact does not exist in the db, so "0 rows" are returned. What is the value to pass to php to start the if - else loop?

Here is a sample of the code:
PHP Code:
<?PHP

     $dbconnO 
pg_Connect ("dbname=contact_data user=httpd password=httpd");

    if (!
$dbconnO) {
             echo 
"</table>A dbconnO error occurred.\n";
             exit;
             }

    
$rsltTEST pg_Exec($dbconnO,
    
"SELECT job_no
    FROM proj_contact
    WHERE proj_contact.job_no = '$cntct_jno';"
);


    if (
$rsltTEST == 0) {
                    echo 
"No job number exists.\n";
                    exit;
                    } else {
I'm sure there is a very simple answer to this but I haven't come across it yet! Thanks for your time and attention!
tomycon is offline   Reply With Quote