FOR WHILE statement similar to this which has the following syntax
for (counter initialitation; requirement; increment/decrement counter)
{
statement;
}
{
statement;
}
To clarify the understanding of the FOR, the following is an example of the code for to produce a display similar to the previous example while (about the amount of brush and price). Compare this to the previous code sample while.
example:
example:
<?
$harga_sikat = 1500;
echo "<table border=\"1\" align=\"center\">";
echo "<tr><td><b>Jumlah Sikat</b></td>";
echo "<td><b>Harga</b></td></tr>";
$harga_sikat = 1500;
echo "<table border=\"1\" align=\"center\">";
echo "<tr><td><b>Jumlah Sikat</b></td>";
echo "<td><b>Harga</b></td></tr>";
for ($jumlah_sikat = 10; $jumlah_sikat <= 100; $jumlah_sikat+=10)
{
echo "<tr><td>";
echo $jumlah_sikat;
echo "</td><td>";
echo "Rp. ".$harga_sikat * $jumlah_sikat;
echo "</td></tr>";
}
{
echo "<tr><td>";
echo $jumlah_sikat;
echo "</td><td>";
echo "Rp. ".$harga_sikat * $jumlah_sikat;
echo "</td></tr>";
}
for ($jumlah_sikat = 10; $jumlah_sikat <= 100; $jumlah_sikat+=10)
{
echo "<tr><td>";
echo $jumlah_sikat;
echo "</td><td>";
echo "Rp. ".$harga_sikat * $jumlah_sikat;
echo "</td></tr>";
}
{
echo "<tr><td>";
echo $jumlah_sikat;
echo "</td><td>";
echo "Rp. ".$harga_sikat * $jumlah_sikat;
echo "</td></tr>";
}
No comments:
Post a Comment