A simple PHP Dynamic Multiplication Table
By Alexies Iglesia
Using PHP we can build a lot of great web applications and websites. With your knowledge in HTML, CSS, Javascript, jQuery and other web development tools, you can make almost everything you want.
Today I'm going to give you a simple code on how to make a simple multiplication table using PHP. It has two pages. The first page will get the input from the user, while the second page will show the output.
I used this as an introductory lesson for my student at Mondriaan Aura College. But starting from now, I'll gonna share some of my resources online for the benifits of a lot of beginners who wants to study this code.
Today I'm going to give you a simple code on how to make a simple multiplication table using PHP. It has two pages. The first page will get the input from the user, while the second page will show the output.
I used this as an introductory lesson for my student at Mondriaan Aura College. But starting from now, I'll gonna share some of my resources online for the benifits of a lot of beginners who wants to study this code.
For those who want to download the file, download it here
1st PAGE ("page1.php")
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action = "page2.php" method="POST">
X value<input name="x"type="number" /><br/>
y value<input name="y" type="number" /><br/>
<input type="submit" value="Generate">
</form>
</body>
</html>
2nd PAGE ("page2.php")
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$x=$_POST['x'];
$y=$_POST['y'];
for ($i=1;$i<=$y;$i++){
echo "<table border='1' ><tr ><td width='30px'>".$i."</td>";
for ($a=2,$b=1;$b<$x;$b++,$a++){
echo "<td width='30px' >".$a*$i."</td>";
}
echo "</tr></table>";
}
?>
</body>
</html>


hi i am a new student tryingg to learn coding. Do you have this code ?
ReplyDelete