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;
}

?>

Discuss this tutorial at forum


Further readings
Checking variables by isset
switch
For Loop
if else condition checking
while loop
Do while loop
PHP Functions
Returning value from a Function
Returning Array from Function
Array as input to Function
PHP beginners guide

 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
Date & Time
Array
String Functions
Math Functions
Form Handling
File Handling
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.