Atouray
asked on
printing a formatted multiplcation table
I want write a PHP code to print multiplication table with a certain format. attached is the format i want.
how it works--You have two cells spanned together and the result of those two are are multiplied with the column. this will give you the X like structure in the table.
I have included a code that will only print a multiplication table without that format.
how it works--You have two cells spanned together and the result of those two are are multiplied with the column. this will give you the X like structure in the table.
I have included a code that will only print a multiplication table without that format.
?>
<HTML>
<HEAD>
<TITLE>A division table</TITLE>
</HEAD>
<BODY>
<FORM ACTION="<?php echo $_SERVER[PHP_SELF];?>" METHOD="POST">
<P>Please enter the matrix
<input type ="text"; size=5; name="end_num" VALUE="<?php echo $_POST['end_num']; ?>">
<H2>A division table</H2>
<TABLE BORDER=1>
<?php
print("<TR>\n");
print("\t<TH> </TH>\n");
for ($row = $start_num; $row <= $limit; $row++)
{
print("\t<TH>$row</TH>\n");
}
//print("</TR>\n");
for ($row = $start_num; $row <= $limit; $row++)
{
print("\t<TR><TH>$row</TH>\n");
for ($column = $start_num; $column <= $limit; $column++)
{
$result = $row * $column;
printf("\t<TD>%.3f</TD>\n",$result); // see Chapter 8
}
// print("</TR>\n");
}
?>
</TABLE>
</BODY>
</HTML>
Doc1.doc
May you please clarify what problem you are encountering? I just inputted two sample variables:
$start_num=4;
$limit=20;
And it generates your multiplication matrix just fine....
$start_num=4;
$limit=20;
And it generates your multiplication matrix just fine....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER