I have somehow managed to Code a working system to delete a row from a Table retrieved from Database.
There is a problem with my code which i couldnt correct
Jquery function to delete and slide up the row
<script type="text/javascript">
$('document').ready(function() {
$('a').click(function() {
if (confirm("Are you sure?")) {
var del_id = $(this).attr('id');
var parent = $(this).parent().parent();
$.post('delete.php', {id:del_id},function(data){
parent.slideUp('slow', function() {
$(this).remove();
});
});
}
return false;
});
});
</script>
Below is the PHP code for the Retrieved Table
<?php
while(($row = mysqli_fetch_assoc($result))) {
echo "<tr>";
echo "
<td>
<span class='label label-red'>".$row['lid']."</span>
</td>
<td>
".$row['name']."
</td>
<td>
<a href='#'>".$row['email']."</a>
</td>
<td>
".$row['tel']."
</td>
<td>
Mental Stress Relief
</td>
<td>
<a href=\"javascript:return(0);\" id=".$row['lid'].">Delete</a>
</td>
";
}
?>
Everythings working fine.
But the Navigation Menu uses the same <a> tag, So when I click the navigation link from this page .. its slides up just as the table row. I couldnt navigate... Should i Use ID or something??
<ul class="navigation">
<li><a href="dashboard.php" class="blblue">Statistics</a></li>
<li><a href="leads.php" class="blyellow">Lead Detials</a></li>
<li><a href="includes/logout.php" class="blred">Logout</a></li>
</ul>
I am confused. What to do?
<a href="javascript;void(0)" class="delete_row"></a>' and$('a').click(function(){` line change into$(".delete_row").click(function(){