The basic PHP datagrid requires only as little as TWO
lines of code. Foremostly, always create phpGrid object
in the first line; then call its methods to define properties, and lastly always call display()
to render 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.
- parameter 1: SQL statement
- parameter 2: SQL primary key
- parameter 3: SQl table name
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg -> display();
See Live Example!
Programming Tip: Database Naming Standards
It’s generally not recommended to have dash or space character in naming database tables, or you must add surrounding quotes, or backticks to the table names or columns that have those characters in the query.
Underscore character, on the other hand, is generally accepted for naming convention.
SELECT * FROM `my-table` -- requires ` around table name
SELECT * FROM my_table -- does not require surrounding quotes.