Using While Loops in PHP
The difference between computers and humans is that computers can be told to perform the same task repeatedly without ever getting tired. To give such commands to a computer, you can use loops.
The While Loop
Example of a while loop script
When executed, the while loop above produces the following repetition:
Result of the while loop script
The Do While Loop
Do while is another technique for creating loops, with the main difference being that the conditional statement is placed at the bottom. If the previous code is converted to a do while loop, it looks like this:
Do while script
The output will appear as follows:
Do while used for repetition