Live Examples

If you are new to phpGrid, we recommend that you go through the examples in the sequence provided. Please note, certain features, such as inline editing and delete, are disabled in live examples.

In addition to the examples, major phpGrid features can be seen in Screenshots page.

Example 1: A Basic PHP Datagrid

The basic PHP datagrid requires only as little as five lines of code. Foremostly, always create phpGrid object in the first line; then call its functional methods to define sql SELECT string, sql table name, sql primary key, and relative path to phpGrid; finally, always call display() to render output to screen.

Please note in some databases, such as Firebird, MS Access, the fields name are case-sensitive. Make sure the name used in the code matches the case when you are using those type of databases.

$dg = new C_DataGrid($hostName, $userName, $password, $dbName);
 
$dg -> set_gridpath     ("include/");
$dg -> set_sql          ("SELECT * FROM Employees");
$dg -> set_sql_table    ("Employees");
$dg -> set_sql_key      ("EmployeeId");
$dg -> display();