No value in database...Newbie help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamesloi
Forum Newbie
Posts: 15
Joined: Thu Jul 15, 2004 5:11 am
Location: London

No value in database...Newbie help

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_fetch_*() / mysql_num_rows()


Moved to PHP - Code.
Post Reply