View Full Version : Squares PHP program

11-19-2011, 07:20 PM
I need help with creating a PHP program with a table that will calculate the following: If anyone can help me get going with this I would greatly appreciate it!:confused


The square of 1 is 1
The square of 2 is 4
The square of 3 is 9
The square of 4 is 16
The square of 5 is 25
The square of 6 is 36
The square of 7 is 49
The square of 8 is 64
The square of 9 is 81
The square of 10 is 100

Thanks in advance!

11-19-2011, 07:27 PM
You have already asked this question, and it was answered here:


11-19-2011, 07:47 PM
Yes, but it did not work for me!:

11-19-2011, 07:49 PM
Then post in that forum what you are doing, what is not working, and what you are trying to do. There is no need making a new topic when you can get the answer in your other post. ;)

11-19-2011, 08:07 PM
This will work, sorry about the last thread lol


function sq($n) { return $n * $n; }

for($i = 1; $i<50; $i++)
echo "The square of $i is ". $i*$i ."<br />";



11-19-2011, 08:30 PM
Yes! Thanks so much!:D