p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Detecting empty set return from mysql query


Message #1 by "Anthony Bollino" <abollino@w...> on Sun, 8 Sep 2002 23:35:33 -0400
Hello,
I am working on a project that will display records on a school website.  If
there are no records for that particular teacher, I want to prompt them to
enter a new record.  I've tried using !isset(), is_null, and NULL to test
the query for the empty set, but my code doesn't seem to pick it up.
What's the best way to detect if a query returns an empty set for a value?

Tony Bollino
Technology Coordinator
Governor Thomas Johnson Middle School
Frederick, MD
anthony.bollino@f...
abollino@w...
http://www.tjmiddle.org/


Message #2 by "jorge" <jorge@d...> on Sun, 8 Sep 2002 22:54:48 -0500
Hi try
if(mysql_num_rows($query) ==0){do this}

Jorge

----- Original Message -----
From: "Anthony Bollino" <abollino@w...>
To: "beginning php" <beginning_php@p...>
Sent: Sunday, September 08, 2002 10:35 PM
Subject: [beginning_php] Detecting empty set return from mysql query


> Hello,
> I am working on a project that will display records on a school website.
If
> there are no records for that particular teacher, I want to prompt them to
> enter a new record.  I've tried using !isset(), is_null, and NULL to test
> the query for the empty set, but my code doesn't seem to pick it up.
> What's the best way to detect if a query returns an empty set for a value?
>
> Tony Bollino
> Technology Coordinator
> Governor Thomas Johnson Middle School
> Frederick, MD
> anthony.bollino@f...
> abollino@w...
> http://www.tjmiddle.org/
>
>
>


Message #3 by Peter Simard <peter@p...> on Mon, 9 Sep 2002 00:08:22 -0400
$results = mysql_query($sql);
if(!$results)
            {
             do something
            }

-- 

 Peter                            
mailto:peter@p...

Mail management by:
The Bat! 1.61



  Return to Index