title: javascript inside php while loop
body: <p>i have this code:</p>
  
  <pre><code>&lt;?php
  $i=5;
  while($i &gt; 0){
  echo '
  &lt;table width="500px" border="1"&gt;
    &lt;tr&gt;
      &lt;td&gt;
      &lt;button id="button"&gt;Show comments&lt;/button&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td id="comments" style="display:none;height:300px;width:100%;"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;script type="text/javascript"&gt;
  $("#button").toggle(
      function (){
          $("#button").text("Hide Comments");
          document.getElementById("comments").style.display="inline";
      },function (){
          $("#button").text("Show Comments");
          document.getElementById("comments").style.display="none";
      }
  );
  &lt;/script&gt;
  &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
  ';
  
  $i--;
  
  }
  ?&gt;
  </code></pre>
  
  <p>When the show comments button is clicked the comment box should show up. It works for the first one. But it doesn't work for the others.What's wrong?</p>