When I run this example in my browser, I see something like Figure 3.
Figure 3. After running the 'show tables' query
In this case, I use the nasa database that I built for a lecture I gave at NASA Ames (yes, I used the "rocket science" joke, because I was talking to a bunch of rocket scientists). The database contains a single table called mission, which includes the name and year of each of the unmanned missions that NASA has launched.
I can sort by name by just clicking on the name column in the data grid, as shown in Figure 4.
Figure 4. Showing the data from the mission table
Then, I can sort by year by just clicking on the year column, as you can see in Figure 5.
Figure 5. The disco ball query
Looks like we haven't launched a whole lot of missions in the last couple of years.
From here, there are a lot of places I could take this example. On the front end, in Flex, I could add some more user-friendly controls to add, remove, or update tables. I could even go as far as providing data filtering or editing functionality that would change the data in the tables. The data grid control is powerful enough to handle in-place editing. Or I could take it in a completely different direction and use the Flex charting package to do some data analysis and visualization.
I see a lot of potential for the combination of PHP and Flex. PHP makes it easy to deliver web services on the back end, either exclusively or in combination with an HTML front end. I'd love to see PHPMyAdmin extended with a web services interface that would let anyone write front ends in Flex, Ajax, Silverlight, desktop widgets, or whatever.
Flex provides a solid front-end tool for PHP developers. It gets around the client-side incompatibility issues that plague Ajax developers. With Flex 2, it's not tied to a specific server technology, so after the Flex application is compiled, it can be deployed anywhere, because it's just a SWF file. And as you can see, with easy web service objects and the powerful E4X language extension, it's very easy to have Flex applications talk to almost anything on the back end.
I hope you give it a try, and if you do some fun stuff with PHP and Flex, let me know and perhaps we can write an article about it together.
- Flex is an open-source Flash application development language originally created by Adobe.
- The MDB2 PEAR module is what I used to access the database.
Jack Herrington is an engineer, author and presenter who lives and works in the Bay Area. His mission is to expose his fellow engineers to new technologies. That covers a broad spectrum, from demonstrating programs that write other programs in the book Code Generation in Action. Providing techniques for building customer centered web sites in PHP Hacks. All the way writing a how-to on audio blogging called Podcasting Hacks.
Return to ONLamp.