title: MySQL Query onclick event on table row
body: <p>I intend to run a query onclick event on table row. </p>
  
  <p>I have created a function in javascript and I can read the id of each row. </p>
  
  <p>Now I wanted to be able to run a query with this id as a condition. </p>
  
  <p>Can they help me please? </p>
  
  <p>Realize my question? </p>
  
  <p>Below I show my code.</p>
  
  <p>-------------Javascript Function-----------------!</p>
  
  <pre><code>    &lt;script&gt;
  function addRowHandlers() {
      var table = document.getElementById("tableId");
      var rows = table.getElementsByTagName("td");
      for (i = 0; i &lt; rows.length; i++) {
          var currentRow = table.rows[i];
          var createClickHandler = 
              function(row) 
              {
                  return function() { 
                                          var cell = row.getElementsByTagName("td")[1];
                                          var id = cell.innerHTML;
                                          alert("id:" + id);
                                   };
              };
  
          currentRow.onclick = createClickHandler(currentRow);
      }
  }
  window.onload = addRowHandlers();
  &lt;/script&gt;
  </code></pre>
  
  <p>-----Query I intend to run-----------</p>
  
  <pre><code>$result= mysql_query("select * from tasks where idTask = id");
  
  while($row = mysql_fetch_array($result))
  {
      $image = $row['image'];
      header("Content-type:image/jpeg");
      echo $image;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/WHzds.png" alt="enter image description here"></p>