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


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
$lname</a><br><b>Firm/Organization:</b> $firm<br><b>Location:</b> $city,
$province<br><b>Specialty:</b> $area<br>&nbsp;</li>\n";

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

Reply via email to