Home arrow PHP arrow Page 6 - Ordering Columns in DDBB Search Results

The Final Words - PHP

This article will show you the fastest way to order your database results, via JavaScript (with some work in PHP). It adds some more work to your script, but once you see the results you won't use the approach of adding the ORDER By clause anymore.

TABLE OF CONTENTS:
  1. Ordering Columns in DDBB Search Results
  2. The Test Scenario
  3. The Basic Code
  4. We Love InnerHTML!
  5. I Need More!
  6. The Final Words
By: Alvaro Calleja
Rating: starstarstarstarstar / 13
December 06, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

In this article we've explored a nice example of how to sort the results of a database search in real time, giving the user a fast response which he or she will surely appreciate. It's not a lot of extra work to do, and I think it's really worth it.

By the way, I like the idea of PHP generating JS that generates HTML!!

Of course, there is a major problem with this trick. If the user browser is too old and doesn't know what innerHTML is, we're in trouble. This trick should only be used if you detect that the user's browser can handle the innerHTML property. If it can't, the "older" approach I explained on the first page of the article could be used, maybe with a message to the user: "Why do you think software companies develop newer versions of their browsers?"

This code was tested succesfully in a P4 1'8 GHz 256 Mb RAM with Windows 2000 Professional, Apache/1.3.27, MySQL 4.0.12, PHP 4.3.1 with the following browsers: Mozilla 1.4 and IE 6.0. It may not be 100% bug free, so I'd appreciate any feedback!

There is an online sample in http://www.karontek.com/koas/order.php

Have fun, and happy coding!!!



 
 
>>> More PHP Articles          >>> More By Alvaro Calleja
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: