Elle0000
08-14-2006, 06:32 PM
I was given the code for an example of a 10x10 table.
I have to create one of my own but I don't understand what each line's specific function is. I can't create a table if I don't understand what the code means or how it works.
I understand the HTML but not most of the PHP code. Lines 8-10 assign values. Beyond that, I just don't get it. I don't understand how to tell that there is a loop or even nested loops.
1: <html>
2: <head>
3: <title>Exercise 1</title>
4: </head>
5: <body>
6: <H1 align="center">Exercise 1</H1>
7: <?php
8: $username = "Jane";
9: $x_val = 5;
10: $y_val = 7;
11: echo "<p>Welcome, <b>$username</b>!</p>";
12: echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\">";
13: for ($y=1; $y<=$y_val; $y++) {
14: echo "<tr>";
15: for ($x=1; $x<=$x_val; $x++) {
16: echo "<td align=center>";
17: echo (($x - $y) * ($x + $y));
18: echo "</td>";
19: }
20: echo "</tr>";
21: }
22: ?>
23: </body>
24: </html>
I have to create one of my own but I don't understand what each line's specific function is. I can't create a table if I don't understand what the code means or how it works.
I understand the HTML but not most of the PHP code. Lines 8-10 assign values. Beyond that, I just don't get it. I don't understand how to tell that there is a loop or even nested loops.
1: <html>
2: <head>
3: <title>Exercise 1</title>
4: </head>
5: <body>
6: <H1 align="center">Exercise 1</H1>
7: <?php
8: $username = "Jane";
9: $x_val = 5;
10: $y_val = 7;
11: echo "<p>Welcome, <b>$username</b>!</p>";
12: echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\">";
13: for ($y=1; $y<=$y_val; $y++) {
14: echo "<tr>";
15: for ($x=1; $x<=$x_val; $x++) {
16: echo "<td align=center>";
17: echo (($x - $y) * ($x + $y));
18: echo "</td>";
19: }
20: echo "</tr>";
21: }
22: ?>
23: </body>
24: </html>