While Loop in Php

While loop saves your time. If you want to print all mysql rows, all value in array, you can use While loop.

Simple Example;


$i = 0;
while ( $i <= 10 ) {
echo "Number: " . $i;
$i++;
}


First; we defined $i as '0'. After we started the While loop statement. If $i number is less or equal to '10', process will continue. If $i number equals to '10', process will end and PHP will continue to generate page.

Here is other syntax.

$i = 1;
while ($i <= 10):
echo $i;
$i++;
endwhile;


While, Foreach, For Next loop statement are save your time to listing any mysql result.