Things You'll Need:
- PHP IDE or a text editor
- MySQL database server configured to work with PHP
- PHP 5, installed and properly configured
- Web server (preferably Apache)
-
Step 1
Define the variables you will use and assign them an initial value:
$count = 1;
$total = 15; -
Step 2
Define the condition that is to be checked:
while ($count <= 10) -
Step 3
Define the actions to be taken while the condition is still true:
{$total = $total + $count;
echo "The total amount is $total ";
$count++;
} -
Step 1
See if your code looks like this:
$count = 1;
$total = 15;
while ($count <= 10) {
$total = $total + $count;
echo "The total amount is $total";
$count++;
} -
Step 2
Check for syntax errors and run the code. It must check if the count value is less than or equal to 10. While it is less than or equal to 10, the total value will be increased with the value of count. After each increase of the total value, the count variable is increased with 1 ($count++), so that the loop will end when the count value reaches 10.












