1

I am using JQuery autocomplete like so:

<ul id="searchFilter">
    <li><input name="searchtext" id="searchtext" placeholder="Search..." /><input type="submit" class="prontoSubmit"  id="submit" name="submit" value="Go" />
    </li>
</ul>

and then the Jquery

$('#searchtext').autocomplete({source:'search.php', minLength:2});

which makes a call to search.php that returns results based off $_REQUEST['term'] and I can see it my next work calls, thats working and is giving expected results:

[{"label":"Parkside Semi II, Hamilton, Greenhill Glen","value":"Parkside Semi II"},{"label":"Parkside Semi, Hamilton, Greenhill Glen","value":"Parkside Semi"},{"label":"Parkside, Hamilton, Greenhill Glen","value":"Parkside"},{"label":"Parkview, Beamsville, Discovery","value":"Parkview"}]

but my autocomplete is not displaying the results...what am i doing wrong?

Here is the code in search.php

<?php

include("classes/FunctionsClass.php");
include("classes/Class.php");

$functionClass = new FunctionsClass;
$class = new Class;

$connection = $functionClass->getConnection();

echo json_encode($class->getSearch($connection, $_REQUEST['term']));

?>

$connection is my sqli connection (which works) and here is my class:

function getSearch($connection, $term){
                $query = mysqli_query($connection, "SELECT home_title, rb_locations.locationLabel, rb_communities.rb_communityLabel FROM readyBuilt INNER JOIN rb_communities ON rb_communities.rb_communityId = readyBuilt.home_community INNER JOIN rb_locations ON rb_locations.locationId = readyBuilt.home_location WHERE home_title LIKE '" . $term . "%'");
                $results = array();
                while($row = mysqli_fetch_array($query)){
                        $results[] = array(
                                'label' => $row['home_title'] . ', ' . $row['locationLabel'] . ', ' . $row['rb_communityLabel'],
                                'value' => $row['home_title']
                        );
                }
                return $results;
        }
James Suske
  • 91
  • 2
  • 13

0 Answers0