Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php5/mysql finding/display records by 1st letter, then 2nd letter, etc

    I'm relatively newbie ... but... Is there any way to use a form to search a client table by entering the first letter of the client's last name to narrow the list, then enter the 2nd letter to narrow the search further, etc? with more than 4,000 client records it would be nice to look for "Baker, Thomas" by starting with a "B", then the "a", then the "k", and so on....

    Any assistance would be greatly appreciated.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    This kind of interactivity will require the use of AJAX. The general process is use Javascript to catch the "keypress up" or "change" event of the text box, which fires off an AJAX request with the contents of the text box, performs a SELECT whatever WHERE last_name LIKE 'string%', and returns the results back to your page. The easy part, really, is the PHP script, which is the simple SELECT and return of results. The more involved part is the AJAX call. You may find more help on that over in the AJAX forum.

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,147
    Thanks
    2
    Thanked 333 Times in 325 Posts
    An example of that process - http://w3schools.com/php/php_ajax_suggest.asp
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •