Live Examples

Example 3: Alternative Background and Mouseover Color

phpGrid also provides additional attributes and methods to color up display. Use set_alt_bgcolor() to define background color of the datagrid. The default is white. Separated the color by comma to have alternative color for each row. Additionally, Use set_onmouseover() Method for onmouseover effect. All of which requires no Javascript! Both hex and HTML color names (e.g Black, White) are valid inputs.

$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");
 
// change column titles
$dg -> set_col_title    ("EmployeeId", "Employee ID");
$dg -> set_col_title    ("LastName", "Last Name");
$dg -> set_col_title    ("FirstName", "First Name");
 
// set background and mouse over color
$dg -> set_alt_bgcolor ("#ffcc99, #ffccdd");
$dg -> set_onmouseover ("yellow");
  $dg -> display();