Re: while....for....problem

From: Date: Mon, 19 May 2003 14:11:11 +0000
Subject: Re: while....for....problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148164@lists.php.net to get a copy of this message
On Monday 19 May 2003 21:02, Simon wrote: What exactly are you trying to do? > Here is the code: > > <?php > $query = "SELECT number FROM table"; > $result = mysql_query($query) or die ("Error in query: $query. " . > mysql_error()); > while($row = mysql_fetch_object($result)) { > $number= $row->number; > ?> > some html > <?php > $e=($number+1)/15; > $c=ceil($e); > for ($i >= '0'; $i <= $c; $i++) { [snip] > Problem is in the 'For' part. It doesn't print all '$i', only for the > first > while loop. In a normal for-loop the 1st expression is usually an assignment (eg $i = 0), but you have a comparison -- this means that $i is never reset, thus $number (the row number) has to be greater than 15 before your for-loop will execute again. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Mason's First Law of Synergism: The one day you'd sell your soul for something, souls are a glut. */

« previous php.general (#148164) next »