We will use the index.php from the Simple Autocomplete
The autocomplete.php code is:
<?php // include the Database driver class (we will use PDO). require_once 'jq-config.php'; require_once "php/jqGridPdo.php"; // include the jqUtils Class. The class is needed in all jqSuite components. require_once "php/jqUtils.php"; // include the jqAutocomplete Class require_once "php/jqAutocomplete.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8"); // create autocomplete instance $ac = new jqAutocomplete($conn); //write the select command $ac->SelectCommand = "SELECT CompanyName FROM customers WHERE CompanyName LIKE ? ORDER BY CompanyName"; // set the source from where to get data. In this case it is the same file. $ac->setSource("autocomplete.php"); // Set the cache option $ac->cache = true; // Enjoy $ac->renderAutocomplete("#company"); ?>