Ämęěr Hěrbawi Ämęěr Hěrbawi - 1 year ago 54
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>


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) {
        type: "POST",
        url: "delete.php",
        data: "id=" + id,
        success: function (html) {
            alert('Successfully Done!!');
    return false;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download