index.PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form method="GET" action="mat.php">
MATRIX MULTIPLICATION </br>
Enter rows & columns of M1:
<input type="text" name="m1" />
<input type="text" name="n1"/></br>
Enter rows & columns of M2:
<input type="text" name="m2" />
<input type="text" name="n2"/></br>
<br /><br />
<input type="submit" name="sub" value="get elements" />
</form>
</body>
</html>
mat.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$m1=$_GET['m1'];
$n1=$_GET['n1'];
$m2=$_GET['m2'];
$n2=$_GET['n2'];
echo "Enter elements of matrix1:"."</br>";
for($i=1;$i<=$m1;$i++)
{
for($j=1;$j<=$n1;$j++)
{
?>
<form method="get" action="print.php">
<input type="text" name="text1<?php echo $i.$j; ?>" />
<?php
}
echo "</br>";
}
echo "Enter elements of matrix2:"."</br>";
for($i=1;$i<=$m2;$i++)
{
for($j=1;$j<=$n2;$j++)
{
?>
<form method="get" action="print.php">
<input type="text" name="text2<?php echo $i.$j; ?>" />
<?php
}
echo "</br>";
}
?>
<input type="hidden" name="m1" value="<?php echo $m1; ?>" />
<input type="hidden" name="n1" value="<?php echo $n1; ?>" />
<input type="hidden" name="m2" value="<?php echo $m2; ?>" />
<input type="hidden" name="n2" value="<?php echo $n2; ?>" />
<input type="submit" value="click" />
</form>
</body>
</html>
print.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?php
$m1=$_GET['m1'];
$n1=$_GET['n1'];
$m2=$_GET['m2'];
$n2=$_GET['n2'];
if($n2==$n1)
{
for($i=1;$i<=$m1;$i++)
{
for($j=1;$j<=$n1;$j++)
{
$a[$i][$j]=$_GET['text1'.$i.$j];
}
}
for($i=1;$i<=$m2;$i++)
{
for($j=1;$j<=$n2;$j++)
{
$b[$i][$j]=$_GET['text2'.$i.$j];
}
}
for($i=1;$i<=$m1;$i++)
{
for($j=1;$j<=$n2;$j++)
{
$c[$i][$j]=0;
for($k=1;$k<=$n1;$k++)
$c[$i][$j]=$c[$i][$j]+ $a[$i][$k]*$b[$k][$j];
}
}
for($i=1;$i<=$m1;$i++)
{
for($j=1;$j<=$n2;$j++)
{
echo $c[$i][$j]. " "." "." ";
}
echo "</br>";
}
}
else
{
echo "multiplication not possible";
}
?>
<body>
</body>
</html>
OUTPUT:
[img]C:\Users\HP\Pictures\Saved%20Pictures\Capture2.png[/img]
[img]C:\Users\HP\Pictures\Saved%20Pictures\Capture3.png[/img]
[img]C:\Users\HP\Pictures\Saved%20Pictures\Capture4.png[/img]