Re: Understanding If conditional statements

From: Date: Mon, 15 Apr 2002 11:15:10 +0000
Subject: Re: Understanding If conditional statements
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-92986@lists.php.net to get a copy of this message
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" <junkit@lmlweb.com> schrieb im Newsbeitrag news:20020414225858.8717.qmail@pb1.pair.com... > 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>&nbsp;</li>\n"; > } > } > >

« previous php.general (#92986) next »