PHP (Hyper Text Preprocessor)

Data Grid Controls in PHP Or Best Three PHP Data Grid Libraries.

Posted on

This class can be used to display data from an SQL database in a sortable HTML table. It can execute a given SQL query and generate HTML and Javascript to display the data in an HTML table. The table listing can be sorted by clicking on the column header titles. Data grid tables can also be displayed using Ajax. 

  • PHP Grid with little config, enables Add, Edit, Del, Auto-filter, Search, Sort, Page, Grouping, Export, Custom Add/Del Calls, Master-detail Grids, Multiple Databases, Customizable Themes and many other features.
  • It’s Secure & Commercially Opensource so you can extend your own core functions.
  • Best suitable for smart engineers, who wish to save development time & effort of creating repetitive CRUD functions through out their projects.
  • Custom SELECT query option is useful for cross table data displaying and Reporting generation. PHP Datagrid Controlis extendable and you can write your own Custom Code-behinds for adding, updating or deleting records.
  • Supports all major databases including Mysql, SQL Server, Oracle, PGSql & ODBC Driver supported databases.

Data Grid Libraries  provides professional-looking Ajax-enabled grid-based editing, create, read, update, and delete (CRUD) operations for Web developers in as little as two lines of code. It features cross-browser inline editing, support for all HTML form controls, integrated search toolbar, a master detail datagrid, image display, MS , HTML and PDF data export, permission control, a theme roller, built-in record sorting by any column, support for major databases including MySQL, SQL Server, and Oracle, support for large database record sets, and some times WYSIWYG and Ajax file upload.

Best 3 PHP Grids are as Follows-

1. phpGrid



Create a fully functional datagrid in PHP for as little as five TWO lines of code.

The phpGrid is a simple, powerful and fully customizable PHP grid control for generating data-bound, AJAX editable datagrid…now with WYSIWYGand file upload support! .

phpGrid is a simple, powerful and fully customizable PHP control for generating data-bound AJAX PHP datagrid… now with WYSIWYG and Ajax file upload support!

phpGrid allow you to create a fully functional datagrid in PHP for as little as two lines of code.

Here are the keyfutures available:

  • Master Detail Datagrid
  • Multiple Editable Datagrids
  • Master with Multiple Detail Grids
  • Column Grouping with Summary
  • Nested Master Detail Grids
  • Theme Roller

2. koolphp


KoolPHP is a vendor of PHP User Interface (UI) components. We focus on building the featured rich yet easy-to-use components to help developers increase productivity and deliver highest quality applications within time and budget constraints. Koolphp is my 2nd best dataGrid that contains a group of great UI controls to help developer build excellent web2.0 application.

Key Features:

  • Cross-browsers compatible
  • Comply to XHTML standard
  • Feature-rich and easy to use controls
  • Abundant ready-to-use examples
  • Working with Zend, CakePHP, Joomla, Smarty.
  • Compatible with Prototype,jQuery, Mootools, Extjs

You can check the Demos

It has a free version with limited features and paid version(less expensive than phpGrid)

3. jqGrid



jqGrid is a grid component for ASP.NET & PHP based on the world’s most popular and flexible jQuery grid plugin.

jqGrid is a grid plugin for the JQuery Javascript library.

jqGrid is free, open source and gets distributed under the MIT license.

Key Features:

  • Works fine under IE, Firefox, Chrome, Safari, Opera
  • The UI comes in 20+ languages
  • CSS customizable
  • Paging and sorting
  • Search and filtering
  • In-place cell editing or on-the-fly form creation to edit a record
  • Supports subgrids and tree grid for displaying hierarchical data
  • AJAX enabled
  • Accepts XML/JSON/local array data sources

Free wrappers for  PHP and ASP.NET exist.

You can view the Demo



Why choose PHP?

Posted on Updated on

These are the reason why php is so popular:

  1. Rapid Application Development
  2. Cloud Ready
  3. Loosely Typed
  4. Open Source
  5. Platform Independent

Let Us examine each of these feature Why PHP  dominates other language

Rapid Application Development

In year 1970 to 1990 computer technology was prevalent only in research centers and universities where programmers struggled to reduce 1KB of memory usage for months I know it may sound a little exaggerated  but it was a reality back in those days when computer technology was evolving from ground up.Now the wheel of technology has taken up a turn, personal computers has brought a revolution a computer in every home.But the number of programmers required to meet the ever increasing  number of applications is insufficient and their development time is very important as compared to computer resources like 1GB of ram which is so cheap now-a-days. PHP is a dynamic interpreted language which thus reduces programmer’s time to compile and deploy.

Cloud Ready

As PHP was designed for the web and cloud is the metaphor for the Internet needless to say PHP is a client server based Cloud Language.Many big Cloud Service Providers provide PHP hosting in their environment.

Loosely Typed

Learning PHP is very easy unlike the complex languages and it doesn’t mean without complexity you cannot make large applications. In fact the basics of software engineering lies in presenting simplicity.When learning PHP you don’t need to take care of int’s or float’s it is handled by PHP Dynamic typing that automates allocation of data types to your data structure.

Open Source

PHP itself is open source, no organization can claim PHP is theirs (Not even Zend can ).The complete code of PHP is open and anyone can use it free of cost thus.Many beginners ask me if Security would be a problem then, to them this is the same thing as you or any developer doing your work alone in a room and in an open environment watched by thousand others.

Platform Independent

PHP is truly platform independent where developers can write their programs on a windows machine and run it on a Linux machine.The power of Platform independence also does not come at a cost of performance.

Let us study whether these features are given by other languages

PHP vs Java

Java advertises the whole day with its Platform Independent WORA (Write Once Run Anywhere) mantra but programmers know it is not 100% achievable and has serious performance drawbacks.PHP on the other hand is Platform Independent and compatible with a whole series of Web Servers. PHP is a clear Winner here in the race of PHP vs Java. While you need to type and compile every java program php programs are dynamic in the sense code can be edited lively on a hot site.

PHP vs C# Dot Net

C# Dot Net is strictly limited to Microsoft’s monopolistic strategies and thus is never free nor platform independent.It is not also cloud ready as its only supported on Azure platform and programming without Visual Studio the programmers become handicapped.

PHP vs C++

No Pointers,  No Data type checks, No compilation needed .If you are one of the few who thinks learning programming should start with C then you might get lost thus PHP is a very good starter.C++ on the other hand cannot be used to develop good web applications.


PHP is the winner between PHP vs All Languages to end the Why PHP debate. Learining a new language is always an advantage and to have PHP in your toolbox it will always serve you a good advantage.And to add to it as I say always

Don’t Marry with any language fall in love with Technology

Now What do you say?

What is the difference between client side and server side validation?

Posted on

Client side validation means the validation of a piece of data is executed on the client’s machine, while the server side validation means that the data is sent to server side first, then the validation is carried out.
This would need some examples to put the terms in context. Client side validation, for most of the software that runs on a PC without network or internet connection, if there is any validation, there is no distinguish of “client” or “server”, because they are the same (the PC).
But for internet (not limited to this, it could be network, 2 iPads) connections for example, let’s say the web page ask you to provide a password entry. The validation of the password entry may occur on both client side and server side. The client side (your internet browser on your PC) validation may use JavaScript to check the length of the password string (not the content of the string) to see if it exceeds a certain length (e.g., minimum of 6 characters). If yes, then the data is sent to server side to be validated (the entered value against the registered value). That server maybe at the other side of the globe.

Client side validation will be written using client side scripts like JavaScript or VB Script. Whereas the server side validation will be written using your server side programming language such as PHP, JSP, PERL or anything you are using. Always go with Server side validation, it will be very helpfull, if your client side script has any error or the script is disabled in client’s browser.

When you submit your e-mail thorough a web form, let say:

If you use client-side validation (Javascript) – the browser (Firefox, IE, Chrome…) will validate the e-mail without having to send it to the server.
Which means, no Internet connection needed, it’s fast since you don’t have to wait for the page to be refreshed to see the validiation..

With Server side validation, everything is the opposite. I would say client side validation is safer.

But, if someone has disabled javascript in their browser then that would mean, their web browser is unable to validiate the form so i guess like the above person indicated.. server side validation would be safer, because they can not turn off server validation in their browser.

Intercepting Execution of System Functions in PHP

Posted on

Intercepting an execution of methods is one of the most common tasks for AOP. In the Java world there are a lot of articles that has a detailed examples for transactional control, logging, authorization, etc. But all AOP stuff in Java is related only to the classes and objects, because functions are not first-class citizens in Java whereas PHP has a good support for functions. By using some tricks we can create a proxies for system functions and add our own interceptors with custom logic. This article will show you how to use AOP techniques with functions in PHP.

Ok, let’s have some experiments with PHP. Suppose, that we have a nice code that uses the file_get_contents() function to load the content of a file and then prints it to the screen:

namespace Test;

class FilePrinter
    public function show($filename)
        echo '<pre>', htmlspecialchars(file_get_contents($filename)), '</pre>';

Is it possible to test this class and method? Of course, yes! We can create a unit test that will generate a temporary file and then just check that content is correct:

namespace Test;

use PHPUnit_Framework_TestCase as TestCase;

class FilePrinterTest extends TestCase
    protected $printer;

    public function setUp()
        $this->printer = new FilePrinter();

    public function testShow()
        $file = tempnam("/tmp", "PHP");
        file_put_contents($file, 'test');
        $content = ob_end_clean();
        $this->assertEqual('test', $content);

Not so cool to use a real filesystem. Real programmers should use virtual file system! But is it possible to intercept system functions like file_get_contents() in PHP?

I can suppose that most of programmers will argue that it’s impossible to intercept system function without extensions such as runkit. Yes, it’s absolutely true that we can not change the function that already loaded into the memory of PHP. However there is a small loophole in the PHP that can be exploited for free.

What is PHP Data Object?

Posted on

PHP Data Object is a Database Connection Abstraction Library for PHP 5.

What is PDO?

  • a PHP5 extension written in a compiled language (C/C++)
  • a Lightweight DBMS connection abstract library (data access abstraction library)

Why PDO?

  • Support great number of database systems supported by PHP
  • You don’t need rewriting of many line code for each database. Just write one and run anywhere
  • Speed. PDO written in compiled language, PHP libraries (ADOdb, PEAR DB) written in an interpreted language
  • Your software more easy to install. Do not need third party software

Whenever you need PDO?

  • You need portable application that support many database system
  • You need speed


we test to connect to database. We use mysql server. Before test, please create a database named “test”. Then create table “books” with query like this:

1 CREATE TABLE `books` (
2   `id` int(11) NOT NULL auto_increment,
3   `title` varchar(150) NOT NULL,
4   `author` varchar(150) NOT NULL,
5   `description` varchar(255) NOT NULL,
6   `on_sale` tinyint(1) NOT NULL,
7   PRIMARY KEY  (`id`)
8 );

Following query for sample data:

1 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (1, 'PHP AJAX', 'Andreas', 'This is good book for learning AJAX', 1);
2 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (2, 'PHP Eclipse ', 'George', 'Nice book', 0);
3 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (3, 'PHP Prado', 'Junyian', '-', 1);
4 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (4, 'PHP Zend Framework', 'Ozulian', 'great', 0);
5 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (5, 'PHP Web Services', 'Bobi', '', 0);
6 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (6, 'PHP API', 'Hugo', '', 1);
7 INSERT INTO `books` (`id`, `title`, `author`, `description`, `on_sale`) VALUES (7, 'PHP SEO', 'Monteo', '', 1);

Now, this is sample connection to mysql database:

01 <?php
02 $host   = "localhost";
03 $db = "test";
04 $user   = "root";
05 $pass   = "admin";
07 $conn = new PDO("mysql:host=$host;dbname=$db",$user,$pass);
09 $sql = "SELECT * FROM books";
10 $q   = $conn->query($sql) or die("failed!");
11 while($r = $q->fetch(PDO::FETCH_ASSOC)){
12   echo $r['title'];
13 }
16 ?>

Copying the data from the original table to the new table

Posted on

Now that we’ve created the backup table it’s simply a matter of running a INSERT INTO … SELECT query to copy the data from the original table into the copy:

INSERT INTO products_bak SELECT * FROM products

Copying the data back again

If something went wrong with your original table after you’ve been mucking around with it, you can then simply delete the data from the original table using TRUNCATE and then use the same query above to copy it back again:

TRUNCATE products;
INSERT INTO products SELECT * FROM products_bak