phpMyDataGrid Logo

Do you need more power and features?
visit phpMyDataGrid Professional



We recommend that you follow the samples in the sequence provided. Some samples are enhancements to previous sample.

Before to start to work, you must create the sample database and tables (or work with your own, as you wish)

If you think that you are stuck, you can try searching in our forum or posting a new thread, (please search before post)

View SQL Code for database and table creation

Now that you had created the SQL let's begin:

Example 1: My first Data Grid

As all classes, phpMyDataGrid requires always create the object in the first line; then call the methods to define fields, permissions, sql table name, sql primary key, order, etc. finally, always call grid() and endGrid() methods to render output to screen.

Some databases do not recognize caps in field names, make sure the field name used in the code matches the case in the table.

View Code - Run sample

Example 2: Formating HTML, defining Path to images and formating fields

HTML output will always be obfuscated, if you need obtain a "readable" HTML output, you can configure it.

Images are not always on the "default" path, or maybe you want to use other images

Each field can be formated accorded to field type.

View Code - Run sample

Example 3: Decimals

You can define the number of decimals and the separator to use in numeric fields

View Code - Run sample

Example 4: POST or GET?, Search By, Totalize columns, My parameters

You can define the "method" which the data will be sent "GET" or "POST"

Totalize numeric columns.

Enable search by feature.

How to forward your own parameters.

View Code - Run sample

Example 5: Header & Footer

Easily create headers and/or footers in the grid

View Code - Run sample

Example 6: Pagination and ordering

Pagination is always automatic, and starts at 20 rows per page, this value may be increased or decreased as you like.

There are 3 kinds of pagination styles "links", "select" and "mixed" (default), try each one and see which one is better for you

You can set the initial order by any field ASCending or DESCending

Also can limit that no ordering arrows will be show in column names

View Code - Run sample

Example 7: Conditionals

Records can be filtered by specifying a WHERE clause

View Code - Run sample

Example 8: Data Maintenance (Add, edit, delete, view)

Keyfield must be defined to indentify each row

Data can be easily processed (added, edited, deleted)

Those process will be protected by a unique code, so nobody can call or try to do anyting ilegal

View Code - Run sample

Example 9: AJAX inline edition

In just one line, enable all the power of inline AJAX edition

View Code - Run sample

Example 10: Calculate values between columns

Sometimes you need to show calculations on screen, if you had used a spreadsheet before, then you will know what I mean.

View Code - Run sample

Example 11: Images

Images can be displayed complementing its name with a field stored data or by simply assigning a name.

View Code - Run sample

Example 12: Links and Images with link

Links are very necesary in data grids, links can be defined as text links or image links with static or dynamic images.

View Code - Run sample

Example 13: Bar charts

For statistical purposes, bar chart can be displayed on datagrid based on thee possibles values (Max number in column, sum of all values in column or a pre-defined value.

View Code - Run sample

Example 14: Everything seems to be amazing but I'm using ADOdb

Using ADOdb is as simple as include the library and modify one line

View Code - Run sample

Example 15: He He Mr Guru, I found a BUG in your DataGrid, page is duplicated inside

Well, this really is not a Bug, is a "situation" that we must handle because as the page reloads itself inside the div, then we must control when an ajax request is located, how can we do this? simply, by intercepting the "DG_ajaxid" variable

View Code - Run sample