Page 1 of 1

No value in database...Newbie help

Posted: Wed Feb 23, 2005 7:08 pm
by jamesloi
Hi..

I am running this code to display all operation details when the page is loaded

Code: Select all

$query = "SELECT * FROM OperationDetails WHERE Date='$date'"; 
        
if ( !($result = mysql_query($query,$link)) ) { 
    echo ("Error connecting to database"); 
} else { 
    if ( $result == 0 ) { 
         echo ("No operations booked"); 
    } else {         
        .....display data
the problem i am getting is that when there are NO fields in the database for the current date the $result is not 0. When i try to echo the result it returns Resource id #3.......

can anyone tell me how i can make it display no operations booked when the query returns nothing ?? :D

Posted: Wed Feb 23, 2005 7:13 pm
by feyd
mysql_fetch_*() / mysql_num_rows()


Moved to PHP - Code.