Skip to content

Instantly share code, notes, and snippets.

@jagroop
Created June 12, 2018 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagroop/f498a5530b791f3194f4a184783bd861 to your computer and use it in GitHub Desktop.
Save jagroop/f498a5530b791f3194f4a184783bd861 to your computer and use it in GitHub Desktop.
sf
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["id"]. "</td>
<td>" . $row["name"]."</td>
<td>" . $row["email"]. "</td>
<td><a href='edit.php?id=". $row["id"] ."'> <button class='btn'>Edit</button></a> <br><br>
<a href='formd?id=".$row["id"]."'> <button id='delete-btn' data-user_id='".$row["id"]."''>Delete </button> </a>
</td>
</tr>";
}
echo "</table>";
} else {
echo "0 results";
}
?>
<!--Dailogue box -->
<script type="text/javascript">
$("#delete").click(function(){
var id = $(this).data('user_id');
var r = confirm('Are you sure to remove this record ?');
if(r == true){
$.ajax({
url: '/formd.php',
type: 'GET',
data: {id: id},
error: function() {
alert('Something is wrong');},
success: function(data) {
$("#"+id).remove();
alert("Record removed successfully"); }
});
}
else{
return false;
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment