The basic PHP datagrid requires only as little as two lines of code. Fore mostly, 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 types of databases.
C_DataGrid($sql_Query, $sql_key, $sql_TableName, $db_Connection);
$sql_Query -> it is a required parameter which represents the SQL Query to select data from the table. generally select query is used.
$sql_Key -> it is a required parameter which represents the primary key of database table.By default it takes ‘id‘ field of database table.
$sql_TableName -> it is also a required parameter which represents the desired database table’s form where you want have to select data.
$db_Connection -> it is an optional parameter which allows datagrid to reference to a difference data source on the fly.
Example: Select data from the database table and displaying into the PHP datagrid.
// connect with database
mysql_connect("localhost", "root", "root");
// select database name
// select value from database table
$dg = new C_DataGrid("SELECT * FROM tempdatabase.tbltemp", "id", "tbltemp");
// change column titles
$dg -> set_col_title("id", "ID");
$dg -> set_col_title("Username", "User Name");
$dg -> set_col_title("EmailId", "Email ID");
$dg -> set_col_title("Address", "Permanent Address");
$dg -> set_col_title("MobileNo", "User Mobile No");
// Display data into screen
$dg -> display(); ?>