Construct a Magic Square by a given number of rows
<p>I'm trying to build an application in simple PHP but could be done in any language.</p>

<p>I want the user to enter number of rows and the output will be the magic square of it.</p>

<p>For example, for $rows=3:</p>

<pre><code>8-1-6
3-5-7
4-9-2
</code></pre>

<p>Notice that in every row,column,diagonal the sum of numbers is equal to 15.</p>

<p>There is a method for constructing this with an odd number of rows. I DONT want that. I want the program to ACTUALLY calculate numbers, row-sums, column-sums and diagonal-sums, doesn't matter if the input is odd or even.</p>

<p>Do you have any idea how to go about doing this? Right now i'm drowning in a sea of loops.
HELP!</p>
