HTML Help
HTML Help Central . com

» Online Users: 63

0 members and 63 guests
No Members online
Most users ever online was 695, 02-16-2011 at 08:01 AM.

» Site Navigation

 > FAQ

» Domains For Sale

Results 1 to 4 of 4

Thread: Math Table

  1. #1
    Join Date
    Jun 2011
    Posts
    6

    Math Table

    Hey all,

    I want to make multiplication tables for 0 through 10. I know how to create the table for one set of times tables, but I don't know how to use a simpler code to make 9 more just like it instead of copy/pasting this code repeatedly for each table. Any insight is appreciated!

    Here is my code:
    <?
    function mul()
    {
    global $start;
    print "<tr>";
    for ($num=1; $num <= 10; $num++ )
    {
    $cell = $num * $start;
    print "<td> " . $cell . " </td>";
    }
    print "</tr>";

    }
    $start = 1;
    $end = 10;
    print "<table border=2 cellpadding=3>";
    $start = 1;
    $times = 1;
    $answer = 0;

    while ($start < 11) {
    $answer = $start * $times;
    print ($start . " x " . $times . " = " . $answer . "<BR>");
    $start++;
    }
    print "</table>";
    ?>

  2. #2
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    1,766
    PHP Code:
    <table border="2" cellpadding="3">
    <?php
      
    function mul($num) {
          echo 
    '<tr>';
          for (
    $i 1$i <= 10$i++) {
              
    printf('<td>%s x %s = %s</td>'$num$i, ($num $i));
          }
          echo 
    '</tr>';
      }

      
    $start 1;
      
    $end 12;  
      while (
    $start <= $end) {
          
    mul($start);
          
    $start++;
      }
    ?>
    </table>
    Last edited by samliew; 06-16-2011 at 05:28 AM.

  3. #3
    Join Date
    Jun 2011
    Posts
    6
    Thanks!

    I am trying to figure out how to separate each column so as not to confuse the user. Is there a way to do this?

  4. #4
    Join Date
    Nov 2012
    Posts
    43
    table, th, td
    {
    border: 1px solid black;
    }
    table
    {
    border-collapse:collapse;
    }
    table,th, td
    {
    border: 1px solid black;
    }
    table
    {
    width:100%;
    }
    th
    {
    height:50px;
    }
    td
    {
    text-align:right;
    }
    td
    {
    height:50px;
    vertical-align:bottom;
    }
    td
    {
    padding:15px;
    }

Similar Threads

  1. Math between arrays
    By Chris in forum PHP
    Replies: 1
    Last Post: 12-01-2009, 03:46 AM
  2. Help displaying Math in HTML
    By radamsiii in forum HTML / XHTML / XML
    Replies: 2
    Last Post: 05-23-2008, 01:38 AM
  3. Javascript math equation
    By Timothy in forum Javascript / AJAX / VBScript
    Replies: 1
    Last Post: 06-02-2003, 10:20 AM
  4. Math.min, Math.max
    By lightnew in forum Javascript / AJAX / VBScript
    Replies: 12
    Last Post: 11-13-2002, 03:41 PM
  5. Math...
    By element in forum Javascript / AJAX / VBScript
    Replies: 10
    Last Post: 09-15-2001, 12:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBadvanced CMPS v4.1.1