I am listing the individuals in my database using Ajax. My index.php and post.php files are set up this way. I store Twitter users in my database and list them here. When I try to delete a user from the database, I am unable to do so. I can create a button to delete it in the form of sil.php?id=123, but it does not get instantly removed from the list that way. How can I ensure that when I click the delete button, the user is removed both from the database and the list without refreshing the page? The index.php code is as follows:
```css
index.php
List a, a:hover{ color:black; text-decoration: none; }
h5 { font-size:1rem; }
p { font-size:0.75rem; }
```
And the jQuery code for fetching data is:
```javascript
$(function() {
$("#cek").click(function() {
$.ajax({
url: 'post.php',
type: 'GET',
success: function(result) {
$('.row').html(result);
}
});
});
});
```
And the code for fetching data in post.php is:
```php
post.php
<?php
require("../db.php");
$cek = $db->query("SELECT * FROM users", PDO::FETCH_ASSOC);
if ($cek->rowCount()) {
foreach ($cek as $row) {
?>
<?php
}
}
?>
```
```css
index.php
List a, a:hover{ color:black; text-decoration: none; }
h5 { font-size:1rem; }
p { font-size:0.75rem; }
```
And the jQuery code for fetching data is:
```javascript
$(function() {
$("#cek").click(function() {
$.ajax({
url: 'post.php',
type: 'GET',
success: function(result) {
$('.row').html(result);
}
});
});
});
```
And the code for fetching data in post.php is:
```php
post.php
<?php
require("../db.php");
$cek = $db->query("SELECT * FROM users", PDO::FETCH_ASSOC);
if ($cek->rowCount()) {
foreach ($cek as $row) {
?>
<?php
}
}
?>
```