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 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2008
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    backend php for autocomplete

    I'm using the jquery autocomplete plugin found here....

    http://www.dyve.net/jquery/?autocomplete

    and I'm getting confused over how the backend PHP code needs to be programmed when the data comes from a mysql db.

    If I follow the example provided at the site, I'm led to believe that I simply echo the array of items pulled from the DB. However, I get absolutely no results in my autocomplete field. My PHP works perfectly fine when I test it by itself so I know I'm retrieving the data correctly

    Here's an example of my PHP script

    Code:
    <?php
    
    include ("connect.php");
    
    $q = strtolower($_GET["q"]);
    if (!$q) return;
    
    $arr=array();
    
    $quer=mysql_query("SELECT * FROM owners where lname like '$q%' order by lname"); 
    while($row = mysql_fetch_array($quer))
    {
      $arr[]=$row['lname'].', '.$row['fname'].'<br />'; 
    }
    foreach ($arr as $value)
    {
      echo $value;
    }
    
    mysql_close();
    
    ?>
    Any insight is appreciated.

    Thanks,

    -Mike
    Last edited by mjl927; 01-24-2008 at 08:33 PM.

  • #2
    New Coder
    Join Date
    Jan 2008
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind. I got it working.


  •  

    Posting Permissions

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