WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

Deletion Process with PDO Ajax

miiksu

New member

0

0%

Status

Offline

Posts

43

Likes

0

Rep

0

Bits

225

4

Months of Service

0%
I am listing the people in my database using Ajax. My files index.php and post.php are set up this way. I store Twitter users in my database and list them here. When I want to delete a user from the database, I cannot do it. I can delete by creating a button like delete.php?id=123, but it doesn't get removed instantly from the list that way. How can I ensure that the user is deleted from both the database and the list without refreshing the page when I click the delete button? Here is the code for index.php:

```html
index.php
List style:
a, a:hover {
color: black;
text-decoration: none;
}

h5 {
font-size: 1rem;
}

p {
font-size: 0.75rem;
}
```

JavaScript code:
```javascript
$(function() {
$("#cek").click(function() {
$.ajax({
url: 'post.php',
type: 'GET',
success: function(result) {
$('.row').html(result);
}
});
});
});
```

Post.php file:
```php
<?php
require("../db.php");
$cek = $db->query("SELECT * FROM users", PDO::FETCH_ASSOC);
if ($cek->rowCount()) {
foreach ($cek as $row) {
// Display user details here
}
}
?>
```
 

249

6,622

6,642

Top