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
<?php
require_once("common.php");
$row=getDetails();
//print_r($row);
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);
header("location:index.php");
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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>
</head>
<body>
<div>
<table border="1" id="main">
<tr>
<td>Link</td>
<td>PageID</td>
<td>Delete</td>
</tr>
<div id="im">
<?php if ($row) { foreach($row as $rs) {?>
<tr>
<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 }} ?>
</div>
</tr>
</table>
</div>
</body>
<script>
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
});
}
}
</script>
</html>