if ($sql_result = 0) if you want to compare $sql_result with 0 you have to do it: if ($sql_result == 0)
= is an assignment operator, == is a comparision operator "Lmlweb" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > 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 { > $advocateID = $row["advocateID"]; > $esc_fname = $row["FNAME"]; > $esc_lname = $row["LNAME"]; > $esc_firm = $row["FIRM"]; > $esc_city = $row["CITY"]; > $esc_province = $row["PROVINCE"]; > $esc_area = $row["AREA"]; > > // strips out special characters before output. > $fname = stripslashes($esc_fname); > $lname = stripslashes($esc_lname); > $firm = stripslashes($esc_firm); > $city = stripslashes($esc_city); > $province = stripslashes($esc_province); > $area = stripslashes($esc_area); > > $option_block .= "<li><b>Name:</b> <a > href=\"advocate_details.html?sel_advocateID=$advocateID\">$fname > $lname</a><br><b>Firm/Organization:</b> $firm<br><b>Location:</b> $city, > $province<br><b>Specialty:</b> $area<br> </li>\n"; > } > } > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php