RE: [PHP] If you ever had a Vic20

From: Date: Mon, 18 Aug 2003 23:36:13 +0000
Subject: RE: [PHP] If you ever had a Vic20
Groups: php.general 
Request: Send a blank email to php-general+get-159966@lists.php.net to get a copy of this message
> [snip] > $found = 0; > while ($mydata = mysql_fetch_object($news)) > { > if ($mydata->StudentId == $StudentId) > {$found = 1; break;} > } > > if ($found==1){do this}else{do that} > [/snip] > > Why two if's? Isn't if the student is found in the first if, don't you > want to do stuff then? Just curious... <late_reply> It's so the "not found" condition can be checked and handled.. You'd still need a second if to handle that.. eg $found = 0; while ($mydata = mysql_fetch_object($news)) { if ($mydata->StudentId == $StudentId) {do this; $found = 1; break;} } if (!$found){do that} </late_reply> Martin

« previous php.general (#159966) next »