테이블 행에서 onclick 이벤트 쿼리를 실행하려고합니다.MySQL 테이블 행 onclick 이벤트
자바 스크립트에서 함수를 만들었으므로 각 행의 ID를 읽을 수 있습니다.
이제이 ID를 조건으로 쿼리를 실행할 수 있기를 원합니다.
나를 도와 줄 수 있습니까?
내 질문을 실현 하시겠습니까?
아래 코드를 보여 드리겠습니다.
------------- Javascript 기능 -----------------!
<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>
는 ----- 쿼리 나는 당신이 당신의 id
을 보낼 Ajax를 사용할 필요가 -----------
$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;
}
ajax.php
("ID :"+ ID가)', 당신은 당신의 PHP 파일에 Ajax 호출을 할 필요가있다. 여기에는 표준 자바 스크립트와 jquery 라이브러리를 사용하는 많은 예제가 있습니다. – Sean답장을 보내 주셔서 감사합니다. PHP 프로그래밍에 익숙하지 않습니다. 좀 더 명쾌해질 수 있겠 니? – rpirez
표준 자바 스크립트를 사용하는 Ajax - jQuery 라이브러리를 사용하는 Ajax - http://stackoverflow.com/questions/8567114/how-to-make-an-ajax-call-without-jquery - http://stackoverflow.com/questions/5004233/jquery-ajax-post-example-with-php와 양쪽 모두 약간 - http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call – Sean