Jump to content

morkofidor

New Members
  • Posts

    6
  • Joined

  • Last visited

morkofidor's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, i got it, it's quite clear after you take a look at it. At first i thought you were beggining in the center, then i saw you were starting from max value then decrementing it. I made your code work the way i want it to. Now i'll try Psycho's code. Thanks guys
  2. Not quite, but it's helpful, thank you I'm trying to get first number on last index, spiraling to the middle. 5 6 7 4 9 8 3 2 1 I need to study the code you provided, i'll get there. Thanks again
  3. Thank you, i'm going to try it out right away
  4. I messed up table generating part: First i should generate row, then columns, naturaly. <?php $i = 0; $j = 0; echo "<table>"; for ($row = 0; $row < $_POST['row']; $row++) { echo "<tr>"; for ($col = 0; $col < $_POST['column']; $col++) { echo "<td>"; $i++; $array[$j] = $i; echo $array[$j]; $j++; echo "</td>"; } echo "</tr>"; } echo "</table>"; ?>
  5. Hello, everyone. Can anybody help me, i'm trying to populate an HTML table with numbers in clockwise order, starting from last cell in the table then spiralling to the center. User inputs number of rows and columns, table is generated, but i'm lost at populating cells with numbers in clockwise order. Here's the code so far: <html> <head> <style> table{ border-collapse: collapse; } table, td{ border: 1px solid black; } td{ width: 50px; } tr{ height:50px; } </style> </head> <body> <div id="input"> <form action="table.php" method="post"> Input number of rows :<br> <input type="text" name="row"><br> Input number of columns:<br> <input type="text" name="column"><br> <input type="submit" name="submit" value="Ok"> </form> </div> <div id="output"> <?php $i = 0; $j = 0; echo "<table>"; for ($col = 0; $col < $_POST['column']; $col++) { echo "<tr>"; for ($row = 0; $row < $_POST['row']; $row++) { echo "<td>"; $i++; $array[$j] = $i; echo $array[$j]; $j++; echo "</td>"; } echo "</tr>"; } echo "</table>"; ?> </div> </body> </html> Array is there because i thought i could populate the table in desired order from array. Any suggestions, directions or links will be appreciated. Please help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.