SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

PHP while loop statement script and example

While loop in PHP is very simple and similar to while loop in C programming. In PHP while loop the condition is checked at the beginning of the loop and the statement inside is executed till the end of the loop, then again the condition is checked and loop executed. Like this loop is continued till the condition became false and  the loop is then stopped. Here if the condition became false inside the loop then also the loop continue to execute till the next time the condition is checked.  Here is one simple example of while loop.



<?
$j=5; // we assigned a value to the variable here

while($j <10 ){   // loop starts if condition is true
Related Tutorial
PHP switch
PHP for loop
PHP file upload
PHP Signup script
echo " value of $j= $j <br>";
$j=$j+1;
}

?>



Further readings
Loops and program structure of PHP scripts
switch
For Loop
if else condition checking
while loop
Do while loop
PHP beginners guide



Join Our Email List
Email:  
For Email Newsletters you can trust
Basic Loops
PHP Sections