Cannot get the codes right in php
<p>I have designed a chess board using loops in php. The board is all well, but I cannot get the chess pieces in right position, because of loops, same picture repeats in every squares of the chess boards. Can anyone suggest me what should I change. Please refer to my codes below.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
th{
   width:80px;
   height:80px;
}
table{
   border: 5px solid orange;
   border-collapse:collapse;
}
td{
   width:80px;
   height:80px;
}
tr{
   width:80px;
   height:80px; 
}
h1{
   color:#6633FF;
}
&lt;/style&gt;

&lt;script type="text/javascript"&gt;

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
   echo"&lt;h1 align='center'&gt;SAJID Chess Board&lt;/h1&gt;";

   echo"&lt;table border='1' align='center'&gt;";

   //Nested For loop starts
   for($i=1; $i&lt;5; $i++)//this is the iteration construct starts from here
{
   echo"&lt;tr&gt;";
   for ($j=7; $j&gt;=0; $j--) // For loop for 1st row

   {
   if(($j%2)==0){
   echo"&lt;td bgcolor='grey'&gt;";
   echo"&lt;img src='king.gif'/&gt;"; //here is the problem, the image of king throughout the chess board                 
   }
  else{
  echo"&lt;td bgcolor='white'&gt;";
  }

  echo"&lt;/td&gt;";
  }//for loop ends
  echo "&lt;/tr&gt;";

  echo "&lt;tr&gt;";

  for($j=0; $j&lt;8; $j++){ // For loop for 2nd row

  if(($j%2)==0){
  echo"&lt;td bgcolor='grey'&gt;";
  }
  else{
  echo"&lt;td bgcolor='white'&gt;";
  }

  echo"&lt;/td&gt;";
  }//for loop ends

  echo "&lt;/tr&gt;";

  }//nested for loop ends

echo "&lt;/table&gt;";

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
