While Loops

   

While loops are another useful construct to loop through data. While loops continue to loop until the expression in the while loop evaluates to false. A common use of the while loop is to return the rows in an array from a result set. The while loop continues to execute until all of the rows have been returned from the result set:

 while($row = mysql_fetch_array($result)) {      // do something with the resulting row } 

You can also use the continue command to skip over the current iteration of the loop, then continue. For example:

 while($row = mysql_fetch_array($result)) {      if($row['name'] ! = "Jet")) {       continue;     } else {       // do something with the row } 

   
Top


Advanced PHP for Web Professionals
Advanced PHP for Web Professionals
ISBN: 0130085391
EAN: 2147483647
Year: 2005
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net