RE: [PHP] Else/For loop

From: Date: Wed, 12 Jun 2002 22:36:21 +0000
Subject: RE: [PHP] Else/For loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-101827@lists.php.net to get a copy of this message
> Being relatively new to php, I discovered the following > after about 2 hours of debugging last night and was wondering why??? > > I had the following code: > > if ( $num_results = 0 ) > { > echo "no records found"; > } > else > { > for ($i=0; $i < $num_results; $i++) > { > display record set > } > } > The duduction...for loops will not work inside else > statements. The question...why? Your deduction is wrong, they do. If this is the code that you're actually using then I suspect that your problem is more in the conditional you've got in your 'if' statement. You aren't doing a compare you're actually setting $num_results to 0. A comparison is '==' rather than just '. -- ---------------------------------------------------------------------- Outback Queensland Internet ************************ Longreach ** New Web Site Online * Queensland ************************ Australia W: www.outbackqld.net.au

« previous php.general (#101827) next »