This guide bridges the gap between the frontend JavaScript grid and the backend PHP server, covering the two most common scenarios: Server-Side Sorting/Filtering and Inline Editing.
/api/grid-data (GET)<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
Last updated: January 2025 – Compatible with AG Grid v31.3+, PHP 8.2/8.3, and MySQL 8.0. aggrid php example updated
- Issue: This mixes PHP logic with the JS view and fails if data needs to be refreshed without reloading the page.
She created a new folder: ag-grid-php-example-updated/. This guide bridges the gap between the frontend
- PHP returns all rows as JSON.
- AG Grid handles filtering/sorting in the browser.
- Problem: Unusable for datasets > 5,000 rows.
File: server.php (main API logic)
She added detailed README.md explaining: Issue: This mixes PHP logic with the JS
3. Critical Issues & Recommendations
A. Security: SQL Injection Risks
If the PHP example constructs database queries based on AG Grid's request parameters (like filtering or sorting), there is a high risk of SQL Injection if not handled correctly.