I intend to run a query onclick event on table row.
I have created a function in javascript and I can read the id of each row.
Now I wanted to be able to run a query with this id as a condition.
Can they help me please?
Realize my question?
Below I show my code.
-------------Javascript Function-----------------!
<script>
function addRowHandlers() {
var table = document.getElementById("tableId");
var rows = table.getElementsByTagName("td");
for (i = 0; i < 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();
</script>
-----Query I intend to run-----------
$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;
}