PHPackages                             mysqlgrid/mysqlgrid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mysqlgrid/mysqlgrid

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mysqlgrid/mysqlgrid
===================

Framework agnostic datagrid - Instantly convert any SQL SELECT statement into a fully featured datagrid

421PHP

Since Apr 2Pushed 10y ago1 watchersCompare

[ Source](https://github.com/escalibore/mySqlGrid)[ Packagist](https://packagist.org/packages/mysqlgrid/mysqlgrid)[ RSS](/packages/mysqlgrid-mysqlgrid/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

mySqlGrid
=========

[](#mysqlgrid)

A powerful and easy to use Ajax data grid for PHP/MySQL

Demo:

MySqlGrid lets you quickly create sortable, searchable, and paginated data grids from *ANY* MySQL SELECT statement including multi-table joins.

- Automatically creates input fields in which a substring can be entered to filter the results.
- Automatically creates dynamically generated drop-down selects.
- Detects date fields and automatically provides pop-up date picker dialogs so users can enter date filters.
- Optionally add controls to edit, view, or delete rows.

MySqlGrid was created with a focus on security, reliability, and simplicity. The learning curve is very minimal. Once you have a valid SQL query, you are minutes away from providing a flexible and beautiful datagrid that will allow your users to quickly find the information they need.

To use mySqlGrid follow these steps:

1. Install via Composer/Packagist.
2. Specify your mysqli database connection in [dbconnect.php](https://github.com/escalibore/mySqlGrid/blob/master/src/dbconnect.php)
3. In your script add "**require \_\_DIR\_\_ . '/vendor/autoload.php';**" per Composer standards.
4. Instantiate class **Mysqlgridmain**, passing in parameters for your SQL Select statement (and any other optional parameters).
5. In the body of your html you will need to create two div elements - one for the datagrid, and one for the pagination area. These two divs must be given ids of "mySqlGridTable" and "mySqlGridPagination", respectively.

For a basic example see [basicgrid.php](https://github.com/escalibore/mySqlGrid/blob/master/basicgrid.php).

#### MySqlGrid works "out of the box" but provides many configuration parameters. Parameters are passed as an array into the Mysqlgridmain object. The parameters are as follows:

[](#mysqlgrid-works-out-of-the-box-but-provides-many-configuration-parameters-parameters-are-passed-as-an-array-into-the-mysqlgridmain-object--the-parameters-are-as-follows)

ParameterTypeDescription**sql**StringA standard mySQL SELECT statement. Any statement that returns rows from your mySQL database will be transformed into a grid. **sql** is actually the only parameter that is required to generate a grid.**includePath**StringThis is the path to the mysqlgrid "src" directory. This is not needed if you do a standard installation via Composer, in which case mySqlGrid assumes the default Composer installation directory (vendor/mysqlgrid/mysqlgrid/src/). **includePath** needs to have a "/" as the last character.**gridId**StringThis is needed if you want to have more than one grid on your page. If this paramater and its sister parameter "paginationId" are not set, MySqlGrid assumes the divs in your page will be "mySqlGridTable" and "mySqlGridPagination" respectively. For example:[basicgrid.php](https://github.com/escalibore/mySqlGrid/blob/master/basicgrid.php). However, to include multiple grids on one page, each grid needs to have uniquely identified divs for both the grid itself and for the pagination area. In such a case you will need to specify paramaters **gridId** and **paginationId**. Here is an example: [multigridSample.php](https://github.com/escalibore/mySqlGrid/blob/master/multigridSample.php)**paginationId**StringSee **gridId** above.**lineCount**IntegerThe number of rows in each paginated grid. If **lineCount** is not specified mySqlGrid will display 25 rows per page.**database**StringIn installations with multiple databases you can specify the database here. Then, in dbconnect.php you would add something like: **if($optionsArray\['database'\]) mysqli\_select\_db($mySqlGridConnection, $optionsArray\['database'\]);****hideColumns**ArraySpecifies columns in the mySQL result set that will not be displayed on the grid. This is handy when you want to get a table's primary key value that means nothing to the user, but will be used to perform an action on a selected row. (See parameters **gridControlHtml** and **gridControlKey**)**hideSelects**ArraySpecifies columns that will not be given dynamic drop-down select capability. They will still be searchable by substring.**noSelects**BooleanWhen set to true this parameter will remove dynamic drop-down select capability from all columns.**noReport**BooleanRemoves the "Report View" button. When the user selects "Report View" button they see a simplified view of the grid table without any controls.**defaultOrderBy**StringYou can include a default "ORDER BY" clause in your SQL, but for performance reasons it's better to specify this as a MySqlGrid parameter. Typically this might look something like: **'ORDER BY Last\_Name DESC'****noSearch**BooleanRemoves entire search row.**noToolTip**BooleanRemoves the question mark that pops up a tooltip.**noReset**BooleanRemoves the "Reset" button.**noPaginate**BooleanWhen set to true this parameter will remove pagination capability. Use with caution: activating **noPaginate** will cause all rows to be downloaded to the browser at once. If the SQL result set consists of many thousands of rows this might not be wanted.**alwaysPaginate**BooleanRemoves the button: "No Pagination"**gridControlKey**StringUsed in conjuction with **gridControlHtml**. This will be the name of the column that represents the unique identifier of the returned result set. Typically this would be a Primary Key field that was included in the SELECT statement but was hidden from the user using **hideColumns**.**gridControlHtml**StringUsed in conjuction with **gridControlKey**. This represents the html that creates controls for individual rows in the grid. You can style the controls as buttons for "view" "update", "delete" for example. Or you can use img tags to make clickable icons that perform actions on the selected row. *The key thing to understand is that wherever you place the string: "gridControlKey" it will be replaced with the value found in the column designated by* **gridControlKey**.

Here are some examples of what this might look like:

'gridControlHtml' =&gt; "&lt;a href='myprocesspage.php?editkey=gridControlKey'&gt;Edit&lt;/a&gt; &lt;a href='myprocesspage.php?deletekey=gridControlKey'&gt;Delete&lt;/a&gt;"

'gridControlHtml' =&gt; "&lt;input type='button' onClick='location.href=\\"?showUpdateForm=gridControlKey\\"' value=\\"Edit\\"&gt;"

'gridControlHtml' =&gt; "&lt;img onClick=\\"view('gridControlKey');\\" src='mysqlgrid/view.png'&gt;&lt;img onClick=\\"edit('gridControlKey');\\" src='mysqlgrid/update.png'&gt;&lt;img onClick=\\"kill('gridControlKey');\\" src='mysqlgrid/delete.png'&gt;"

#### Other Notes:

[](#other-notes)

MySqlGrid checks to see if jQuery is present, and if not, automatically loads it from a local copy. If you otherwise need to load jQuery in your script it is recommended to add it in the head section prior to instantiating the Mysqlgridmain object. #### Acknowledgments

[](#acknowledgments)

A huge thank you to Czarek Tomczak for [ExpandSelect.js](https://code.google.com/p/expandselect/) and to botmonster for [bootpag](http://botmonster.com/jquery-bootpag/#.VZqNtvlViko). You guys are JavaScript geniuses!

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3267730?v=4)[escalibore](/maintainers/escalibore)[@escalibore](https://github.com/escalibore)

---

Top Contributors

[![escalibore](https://avatars.githubusercontent.com/u/3267730?v=4)](https://github.com/escalibore "escalibore (86 commits)")

### Embed Badge

![Health badge](/badges/mysqlgrid-mysqlgrid/health.svg)

```
[![Health](https://phpackages.com/badges/mysqlgrid-mysqlgrid/health.svg)](https://phpackages.com/packages/mysqlgrid-mysqlgrid)
```

###  Alternatives

[dmitrykazak/magento-google-tag-manager

Google Tag Manager (GTM) Extension for Magento 2

112.8k](/packages/dmitrykazak-magento-google-tag-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
