PHP
  Home arrow PHP arrow Ordering Columns in DDBB Search Result...
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Ordering Columns in DDBB Search Results
By: Alvaro Calleja
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2004-12-06

    Table of Contents:
  • Ordering Columns in DDBB Search Results
  • The Test Scenario
  • The Basic Code
  • We Love InnerHTML!
  • I Need More!
  • The Final Words

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Ordering Columns in DDBB Search Results


    (Page 1 of 6 )

    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.

    Introduction

    I bet most of us have at some point developed an application where a list of products is retrieved from a database and shown in a table with its name, price and code. Perhaps some of us thought: "Hey, let's be nice and give the user the chance to order these results by name or price." So we placed a cute little icon near each column's header that linked to the search page with a flag in the URL to let it know we wanted the results ordered by name or price. The search script kindly did its job, adding the ORDER BY clause, and the ordered results were shown to the user.

    Obviously this works, but there is a problem: you must search again in your database, and send the user the whole page with the new results.

    So let's think -- the first time you load the page, the results are already in the user browser. Why must we bother the server again to retrieve the same results in a different order?

    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 mentioned above anymore.

    More PHP Articles
    More By Alvaro Calleja


       · Nice. Thanks.With this little change you can sort by clicking on the field names...
       · This will work only if there is no pagination of results
       · How many tables only hold a screens worth of data?This is a nice example but not...
       · If this script does not function properly for you, it may be neccessary to make...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT