I want that table be refresh after deleting data
i have tried it but it’s not working. Can you pls help me how can I do it using protype.js?

this is my code

function getDetails () {
$objLogs = new Logs();
$fields = 'id,link,filename,pageid,position,orderid';
$row = $objLogs->fnSelect('link',$fields,'1=1 ORDER BY orderid');
return $row;
if ($_GET['ref'] == 'delete') {
$condition = 'id='.$_GET['id'];
$objLogs = new Logs();
$r = $objLogs->fnDelete('link',$condition);
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="js/prototype.js"></script>
<script src="js/scriptaculous.js"></script>
<table border="1" id="main">
                <div id="im">
                <?php if ($row) { foreach($row as $rs) {?>
    <td><?php echo $rs['link'] ?></td>
    <td><?php echo $rs['pageid'] ?></td>
                 <td><a href="#" onClick="fnDeleteLink(<?php echo $rs['id']; ?>);">Delete</a></td>
                <?php }} ?>
function fnDeleteLink(id){
                if (confirm("Are you sure to delete?")){
                var pars = 'id=' + id;
                new Ajax.Updater({ success: 'im' }, 'sample.php?ref=delete', {
                method: 'get',
                parameters: pars

From a quick look I got on your post, your Ajax.Updater syntax is totally wrong.
You need to supply a DOM element as an argument, or in plain english,
you must say to Ajax.Updater where you want it to display the results of 'sample.php' (in other words, the place where 'sample.php' will echo)

Supposedly your table is on a <div> with id="mydiv"


var pars = 'id=' + id+'&success=im&ref=delete';
 new Ajax.Updater('mydiv','sample.php', {method: 'get', parameters: pars});

in sample.php, I don't know the Logs class (must be from a non official PHP library), but after you delete the record, and before you redirect to index.php, you have to add

$rows = getDetails();
if (is_array($rows)) {
echo "<table>";
foreach ($rows as $row) {
echo "<tr><td>".$row."</td></tr>;
echo "</table>";
} else {
echo $rows;

By the way, what's the point of using AJAX, if you are to redirect to index.php???

Better forget about redirecting! ;)