Re: checking for 0 results?
| From: | Hp | Date: | Thu, 15 Nov 2001 17:40:39 +0000 |
| Subject: | Re: checking for 0 results? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23391@lists.php.net to get a copy of this message | ||
Use mysql_num_rows() to return the amount of rows selected with your query.
example:
<?php
/* DB connection stuff comes here */
$query = "SELECT * FROM table";
$getdata = mysql_query($query);
if(mysql_num_rows($getdata)){
// output fetched rows
}
else{
echo "no terms";
}
?>
"Jonathan Narong" <jon@binaryillusions.com> wrote in message
news:KLEHIEPKGMOHKIMODPDHAEBCCFAA.jon@binaryillusions.com...
> maybe i'm totally not thinking straight right now, but is there a way in
php
> to check if 0 results are returned in a mysql query?
>
> for example, i have a definition database, that has a list of letters the
> user clicks on (click on the letter, and all the terms for that letter pop
> up).. but for some letters there are no terms. so i just wanted to echo
out
> a simple "no terms" message or something. in any case, i need to check if
> there are no results from a mysql query (an error won't be returned).
>
> thanks ..
>
> -jon
>
>