Page 1 of 1

How would you create a PHP Multiplication that looks like:

Posted: Mon Feb 11, 2008 10:03 am
by rawleanoop
Image

That's what i'm trying to create.
What I've been able to figure out so far is:

Code: Select all

<html>
<table border="1"> 
<tr>
<th></th>
<?php
for($i=1; $i<=9;$i++){
echo "<th>", $i, "</th>"; //print the column header
}
?>
</tr>
<?php
for ($i=1; $i<=9; $i++){
echo "<tr>";
echo "<td><i><b>", $i, "</b></i>"; //print the row header
for ($j=1; $j<=9;$j++){
echo "<td>"; $k=$j*$i; echo $k; echo "</td>\n";
}
echo "</tr>\n";
}
?>
</table>
</html>
 
Any ideas? Please help!

Re: How would you create a PHP Multiplication that looks like:

Posted: Mon Feb 11, 2008 10:09 am
by onion2k
You appear to be trying to make a 10 by 10 table rather than 10 separate tables. Is that intentional?

Re: How would you create a PHP Multiplication that looks like:

Posted: Mon Feb 11, 2008 10:12 am
by rawleanoop
I was able to figure that out. I'm still working on how I would create the tables. I don't want a 10x10 table.

Re: How would you create a PHP Multiplication that looks like:

Posted: Mon Feb 11, 2008 10:17 am
by onion2k

Code: Select all

<?php
 
    for ($x = 1; $x < 11; $x++) {
        echo "<table style=\"float: left; width: 160px; border: 1px solid #888; margin: 0px 0px 10px 10px;\">";
        for ($y = 0; $y < 11; $y++) {
            echo "<tr>";
            echo "<td style=\"width: 50%\">".$x." * ".$y." =</td>";
            echo "<td style=\"width: 50%\">".($x*$y)."</td>";
            echo "</tr>";
        }
        echo "</table>";
    }
 

Re: How would you create a PHP Multiplication that looks like:

Posted: Mon Feb 11, 2008 10:37 am
by rawleanoop
WOW. 8O

Thank you good sir.