can you give me some samples??thx

Dani AI

Generated

has EyeDataGrid loaded and is printing the people table; asked for the code and pointed toward alternative tools. The simplest, safest approach is to let each row carry the table primary key, render a small delete form or link for that row, and have a separate server-side handler perform a parameterized DELETE. Use POST (not GET), require a confirmation, and protect with a CSRF token or session check.

Steps to implement

  • Ensure your grid query exposes the table primary key (id).
  • Add an action column that outputs a tiny POST form (one per row) with a hidden id and a CSRF token, or use the datagrid library hook for custom columns if it supports that.
  • Create a delete.php that checks request method, validates the id, verifies the token, runs a prepared DELETE, then redirects back to the grid.
  • On success, redirect to avoid duplicate submissions; show a message or refresh the grid.

Example server handler (safe pattern)

// delete.php (outline)
session_start();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') { header('Location: datagrid.php'); exit; }
$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
if (!hash_equals($_SESSION['token'] ?? '', $_POST['token'] ?? '')) { die('Invalid request'); }

$pdo = new PDO('mysql:host=localhost;dbname=people;charset=utf8mb4', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('DELETE FROM people WHERE id = ?');
$stmt->execute([$id]);

header('Location: datagrid.php?msg=deleted');
exit;

Per-row form (rendered inside the grid)

<form method="post" action="delete.php" onsubmit="return confirm('Delete this record?');" style="display:inline">
  <input type="hidden" name="id" value="ROW_ID_HERE">
  <input type="hidden" name="token" value="<?php echo htmlspecialchars($_SESSION['token']); ?>">
  <input type="submit" value="Delete">
</form>

Notes and troubleshooting

  • Use prepared statements to avoid SQL injection.
  • If deletions fail, check foreign-key constraints and error mode.
  • For production, prefer soft-deletes or an admin-only permission check.
  • If EyeDataGrid has a built-in action/column API, use that to inject the form rather than post-processing HTML.

post your code and problem declination briefly....

I download a code in datagrid, but i didnt know the code for delete,
can you help me?

post code...

<?php
// file: ex1.php
require 'class.eyemysqladap.inc.php';
require 'class.eyedatagrid.inc.php';

// Load the database adapter
$db = new EyeMySQLAdap('localhost', 'root', '', 'people');

$dg = new EyeDataGrid($db); // Load the datagrid class
// Fetch all rows and columns from the `people` table
$dg->setQuery("*", "people");

// Print the table
$dg->printTable(); 
?>

here is the code..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.