Specifications

</tr>
<tr>
<td align = right>100</td>
<td align = right>10</td>
</tr>
<tr>
<td align = right>150</td>
<td align = right>15</td>
</tr>
<tr>
<td align = right>200</td>
<td align = right>20</td>
</tr>
<tr>
<td align = right>250</td>
<td align = right>25</td>
</tr>
</table>
</body>
</html>
It would be helpful if, rather than requiring an easily bored humanwho must be paid for his
timeto type the HTML, a cheap and tireless computer could do it.
Loop statements tell PHP to execute a statement or block repeatedly.
while Loops
The simplest kind of loop in PHP is the while loop. Like an if statement, it relies on a condi-
tion. The difference between a while loop and an if statement is that an if statement executes
the following block of code once if the condition is true. A while loop executes the block
repeatedly for as long as the condition is true.
You generally use a while loop when you dont know how many iterations will be required to
make the condition true. If you require a fixed number of iterations, consider using a for loop.
The basic structure of a while loop is
while( condition ) expression;
The following while loop will display the numbers from 1 to 5.
$num = 1;
while ($num <= 5 )
{
Using PHP
P
ART I
44
LISTING 1.3 Continued
03 7842 CH01 3/6/01 3:39 PM Page 44