Solved

printing a formatted multiplcation table

Posted on 2008-10-06
3
603 Views
Last Modified: 2013-12-13
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.
?>

<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>

Open in new window

Doc1.doc
0
Comment
Question by:Atouray
  • 2
3 Comments
 

Author Comment

by:Atouray
ID: 22653270
still no one can contribute,
0
 
LVL 2

Expert Comment

by:AdiF
ID: 22656378
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....
0
 
LVL 2

Accepted Solution

by:
AdiF earned 500 total points
ID: 22656387
Oops sorry I see your file attachment now.....

I don't understand what you are trying to do by doing a colspan on some <TD>'s..... because 2x2 is not the same as 2x3......
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now