Thanks to you both Richard and Bastian. I am a newb and am trying to work alot out for myself. I decided to use the number rows method and validate against that. But now that I know that I should be defining my variables at the top, that will help alot.

jzf



Hutchins, Richard wrote:

Many ways to remove the epidermis from a feline, but...

You may want to do something equivalent (I think you're using mysqlite) to
the mysql_num_rows() function on your result set as a condition to running
your while loop . In pseudocode...

if(mysql_num_rows($result_set) < 1){

        echo out something like <p>no results</p>".    

}else{
        
        your current while... loop      

}

That way, if your query returns no results, you don't try to set the
variables but you communicate that nothing was found.

Best way? Maybe not. I've used it a few times and it's done the trick for
me. Your mileage may vary.

Rich

-----Original Message-----
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 08, 2005 1:23 PM
To: PHP list
Subject: [PHP-DB] empty set query


I have a query which can result in an empty set/ no matching records. The code I have which returns a code is:


$result = mysqli_query($link, $sql);
   while ($query = mysqli_fetch_array($result)){
   $title = $query['title'];
   $director = $query['director'];
   echo "<table><tr><td>$title</td><td> $director</td></tr></table>\n";
     }

If the resulting query is a empty set, which variable or item to I refence as null. I already tried
if (!query) and (!$title)


and neither of them work. I also tried if either of them are null. I don't need someone to give me a long explanation just a small bump as to what I should be referencing. In other words, what is it that I should reference? Should I just write a code that returns number of rows and use that?

Jzf




-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to