- Forums
- PHP
- Do While Loop Learn Programming Do While Loop Example Code Scripts Tutorial
This Page Contains information about Do While Loop Learn Programming Do While Loop Example Code Scripts Tutorial By unix in category PHP with 37 Replies. [1013], Last Updated: Sat May 18, 2024
unix
Sat Mar 31, 2007
37 Comments
8351 Visits
this short tutorial is to show you how you can display information or data with the DO WHILE loop. I will be using php for this. for this sample code to work, you will need php on your website. if you don't have php already, you can visit our friends at webune.com and signup for a php web hosting plan. They have excellent service and i always recommend them to all my customers.
Now there a is good example of a do while loop:
<?php
# This sample code by Wallpaperama.com
# This is a loop that displays a list of numbers 1 through 10
$number_of_loops = 10;
$counter = 1;
do
{
echo $counter.'<br>';
# Increment $counter by 1
$counter ++;
}
# NOTES: The next line checks to see if the number of loops is greater than or equal to ten,
# if its not, then it continues with the loop until the number of loops is more than 10
while ($counter <= $number_of_loops);
?>
if you want to see how this code looks, open your text editor like notepad in Windows and save the file as loop.php, then upload to your PHP website and open it with your browser, when you open the loop.php file with your browser, it will display like this:
1
2
3
4
5
6
7
8
9
10
Remeber, if you need PHP web hosting, visit our friends at www.webune.com
create a program that enable the user to input 4 numbers using while loop and then display the sum of even and odd number and count the number of even and odd number inputted by the user...
https://www.wallpaperama.com/forums/do-while-loop-learn-programming-do-while-loop-example-code-scripts-tutorial-t1005.html