Datatables
This code example shows how to build interactive tables using DataTables's server-side mode, with full support for pagination, sorting, and searching.
CREATE TABLE employee (
id int NOT NULL AUTO_INCREMENT,
name varchar(300),
department varchar(300),
email varchar(300),
PRIMARY KEY (id)
);
INSERT INTO employee (name, department, email) VALUES
('Olivia Chen', 'Marketing', '[email protected]'),
('Benjamin Carter', 'IT', '[email protected]'),
('Sophia Rodriguez', 'Sales', '[email protected]'),
('Liam Goldberg', 'Finance', '[email protected]'),
('Ava Nguyen', 'HR', '[email protected]'),
('Noah Patel', 'IT', '[email protected]'),
('Isabella Kim', 'Marketing', '[email protected]'),
('Mason Williams', 'Sales', '[email protected]'),
('Mia Garcia', 'Finance', '[email protected]'),
('James Johnson', 'IT', '[email protected]'),
('Charlotte Martinez', 'HR', '[email protected]'),
('William Davis', 'Sales', '[email protected]'),
('Amelia Lee', 'Marketing', '[email protected]'),
('Elijah Hernandez', 'IT', '[email protected]'),
('Harper Gonzalez', 'Finance', '[email protected]'),
('Lucas Wilson', 'Sales', '[email protected]'),
('Evelyn Anderson', 'HR', '[email protected]'),
('Alexander Thomas', 'IT', '[email protected]'),
('Abigail Moore', 'Marketing', '[email protected]'),
('Henry Taylor', 'Finance', '[email protected]'),
('Emily Jackson', 'Sales', '[email protected]'),
('Michael White', 'IT', '[email protected]'),
('Sofia Harris', 'HR', '[email protected]'),
('Daniel Martin', 'Marketing', '[email protected]'),
('Madison Thompson', 'Finance', '[email protected]'),
('Jacob Clark', 'IT', '[email protected]'),
('Ella Lewis', 'Sales', '[email protected]'),
('Logan Walker', 'Marketing', '[email protected]'),
('Victoria Hall', 'HR', '[email protected]'),
('David Allen', 'IT', '[email protected]');
How It Works
- Sorting: User clicks a column header → DataTables sends column index + sort direction → server applies
ORDER BY - Global Search: Search bar above table triggers across all columns