In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
says...
> I'm trying to get my code to print out a "sorry - no results" message if
> there is no match. I've read the If statement in the PHP manual
> (http://www.php.net/manual/ro/control-structures.php#control-structures.if)
> 
> and
> 
> I think my code structure may be wrong.. am I wrong to nest it this way in
> the following code? If so, where should I be putting the " if $sql returns 0
> records, then print.." code?
> 
> while ($row = mysql_fetch_array($sql_result)) {
>  if ($sql_result = 0) {
>   $option_block .= "Sorry, your search has resulted in 0 records. Please try
> again. \n";
>   }
>  else {

Firstly, $sql_result insn't the value to check and secondly you should do 
it before you start the while loop.

Do your query to the DB, then check mysql_num_rows. If it is zero, print 
the error message; otherwise go into the while loop to display your 
results.

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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

Reply via email to