PHP Example
Screen shot
To Accept number from User and print table.
<html>
<head>
<title>Code to print table</title>
</head>
<body>
<form action=\"\" method=\"post\">
Enter the Number<input type=\"text\" name=\"num\" value=\"\" />
<br />
<input type=\"submit\" name=\"btn\" value=\"submit\" />
<?php
if(isset($_POST[\'btn\']))
{
$num1=$_POST[\'num\'];
for($i=1;$i<=10;$i++)
{
$t=$num1*$i;
echo \"<br>\".$t;
}
}
?>
</form>
</body>
</html>

Another Example

<html>

<head>

<title>for loop example</title>

</head>

 

<body>

<form name=\"frm\" action=\"\" method=\"post\">

Enter your name

<input type=\"text\" name=\"name\" />

Enter How many times do you print your name ????????

<input type=\"text\" name=\"num\" /><br />

<input type=\"submit\" name=\"btn\" value=\"print my name\" />

</form>

<?php

if(isset($_POST[\'btn\']))

{

$name=$_POST[\'name\'];

$num=$_POST[\'num\'];

for($i=1;$i<=$num;$i++)

                {if($i%2==0){

echo \"<font color=\'red\'>\".$name.\"</font>\".\"<br>\";}

                else{

                echo \"<font color=\'green\'>\".$name.\"</font>\".\"<br>\";}

                }

}

?>

</body>

</html>


\"img12\"

\"img13\"

You can download source code here