Ämęěr Hěrbawi Ämęěr Hěrbawi - 9 months ago 33
PHP Question

Making clickable row



<tr onclick="document.location= 'delete.php?id="<?php $row['id'];?>"'>
<td><?php echo$row['id'];?></td>
<td><?php echo$row['name'];?></td>
<td><?php echo$row['phone'];?></td>
<td><?php echo$row['address'];?></td>

</tr>




where is the problem ????

i need to let the row of table clickable but it does not worked ,and every row will go to diffrent website , i will send "id" in the url and another web will get the "id" through GET method

Answer Source

You could call javascript method and pass the id in it. And, inside your javascript method use ajax.

onclick="callMethod('<?php $row['id'];?>')"

You can write ajaxlike below

function callMethod(id) {
    $.ajax({
        type: "POST",
        url: "delete.php",
        data: "id=" + id,
        success: function (html) {
            alert('Successfully Done!!');
        }
    });
    return false;
}