Astuce #9: Suppression avec drag and drop via AJAX et PHP/PDO

10 Jan 2021 · 9 min
9:24

In this tutorial, the presenter demonstrates how to add a record‑deletion feature to a web application using a drag‑and‑drop interface that triggers an AJAX request to a PHP/PDO backend. The video builds on previously covered JavaScript and PHP snippets, moving the database‑interaction code into a dedicated `contenu.php` file and using an `ajaxIn` function to load and refresh the list of records. Elements representing database rows are made draggable via the HTML `draggable` attribute, and standard drag‑and‑drop events (`dragstart`, `dragover`, `drop`, `dragleave`) are attached. The `drop` handler is modified so that, instead of moving the element, it captures the record’s ID and calls `ajaxIn` with an `action` parameter set to `sup`. On the server side, the PHP script reads the `ID` and `action` parameters; if `action` equals `SUP`, it executes a `DELETE FROM glossaire WHERE id=? LIMIT 1` query using PDO, then re‑outputs the updated list. The presenter notes that the implementation is intentionally simple—lacking confirmation dialogs and security checks—and points viewers to a previous video for a more robust deletion flow.

Chapters

More from Yamossoun

8:56
youtube.com

Compteur synchrone - Logique séquentielle

2w ago
11:58
youtube.com

Compteur asynchrone et diviseur de fréquence - Logique séquentielle

3w ago
11:37
youtube.com

Les registres (parallèle et à décalage) - Logique séquentielle

1mo ago
6:14
youtube.com

Bascule T (Toggle) - Logique séquentielle

1mo ago
12:05
youtube.com

Bascule JK - Logique séquentielle

1mo ago
9:17
youtube.com

Bascule D flip-flop active sur front montant - Logique séquentielle

1mo ago
10:08
youtube.com

Bascule D Latch - Logique séquentielle

1mo ago
8:13
youtube.com

Bascule RS - Logique séquentielle

1mo ago
5:04
youtube.com

Logique séquentielle - Introduction

2mo ago
1:15
youtube.com

Le codeur - Logique combinatoire #codeur #logique #circuit #booleanlogic

2mo ago
1:56
youtube.com

Algorithme de calcule de la racine carrée par dichotomie #dichotomy #squareroot #algorithm

3mo ago
See all content