title: PHP-generated table button onclick works only for the first
body: <p>I have a HTML table generated from PHP (from the results of SQL query):</p>
  
  <pre><code>echo "&lt;table border=\"5\"&gt;&lt;tr&gt;&lt;th&gt;Codice&lt;/th&gt;&lt;th&gt;Titolo&lt;/th&gt;&lt;th&gt;Anno Creazione&lt;/th&gt;&lt;th&gt;Materiale&lt;/th&gt;&lt;th&gt;Altezza&lt;/th&gt;&lt;th&gt;Peso&lt;/th&gt;&lt;th&gt;Museo&lt;/th&gt;&lt;/tr&gt;";
  while($row = mysqli_fetch_assoc($results)) {
          echo "&lt;tr&gt;&lt;td&gt;".$row["Codice"]."&lt;/td&gt;&lt;td&gt;".$row["Titolo"]."&lt;/td&gt;&lt;td&gt;".$row["Anno_creazione"]."&lt;/td&gt;&lt;td&gt;".$row["Materiale"]."&lt;/td&gt;&lt;td&gt;".$row["Altezza"]."&lt;/td&gt;&lt;td&gt;".$row["Peso"]."&lt;/td&gt;&lt;td&gt;".$row["Museo"]."&lt;/td&gt;&lt;td&gt;&lt;button id=\"modifica\" type=\"button\"&gt;Modifica&lt;/button&gt;&lt;/td&gt;&lt;td&gt;&lt;button id=\"cancella\" type=\"button\"&gt;Cancella&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>Then, I have this JQuery:</p>
  
  <pre><code>$("#cancella").click(function(){
      if(confirm("Vuoi davvero eliminare questi dati?")){
          var codice = &lt;?php echo json_encode($cod); ?&gt;;
          var tipo = &lt;?php echo json_encode($tipo_opera); ?&gt;; 
          window.location.href = "delete.php?codice="+codice+"&amp;tipo="+tipo;
      }
   });
  </code></pre>
  
  <p>This click function works only for the "delete" button at the first row. Why?</p>