I purchased Learning jQuery and I'm going through some of the ajax
examples.  On page 219 they have an auto completion example.  I can
get it to work just fine, but what about if you're pulling records
from a database?

For instance, the example shows:

$terms = array('football','baseball');
$possibilities = array();
foreach ($terms as $term){
        if(strpos($term, strtolower($_REQUEST['search-sites'])) === 0)
        $possibilities[] = "'". str_replace("'", "\\'", $term) . "'";
        }
print ('['.implode(', ', $possibilities) .']');

Now, what if I'm pulling a bunch of rows from the database?  Lets say
each row has a record... and it outputs:
football,baseball,basketball.  Looping through I would use:

while ( $row = mysql_fetch_assoc($result)) { $terms[] = $row[site];}

But $terms now doesn't work.  How do I get the db results to create
the correct array that will work in the above example?

Reply via email to