The php code that produced this grid is shown below. As you can see it is very simple. The whole thing is driven by the SQL statement in the first line. The only other compulsory line is the display() at the end that causes the grid to be built.

The rest of the code is just prettying things up and adding additional features such as:

  • Column headings
  • Enabling search and edit
  • and exporting the results to pdf

Try out any of these features for yourself and you'll see how it works:
  • Use the page controls at the bottom to move between pages and/or change the page size
  • Click on any column heading to sort ascending or descending
  • Double click (or click on the pencil symbol) to edit the selected line. Editing can also be via a form or field by field.
  • Click on the + sign to add a row - or the trash can to delete the selected row.
  • Click on the magnifying glass to open up the search option.
  • Click on the export symbol (box with an arrow pointing out) to export the current results to a pdf

You can find more information and samples on the PHPGrid web site (phpgrid.com)

$dg = new C_DataGrid("SELECT CustNo, NAme, City, State, Zip FROM PARTNER400.CUSTOMERSP", 
           "CUSTNO", "CUSTOMERSP");
$dg->set_col_title('CUSTNO', 'Customer #');
$dg->set_col_title('NAME', 'Customer Name');
$dg->set_col_title('CITY', 'City');
$dg->set_col_title('STATE', 'State');

$dg->set_caption("Jon's Simple PHPGrid Demo");
$dg->enable_search(true);
$dg->enable_edit('INLINE');
$dg->enable_export('PDF');

$dg -> display();