Location: PHPKode > scripts > Suggester > suggester/front-end.php
<?
include "Subsys/php.php";
$JsHttpRequest =  new Subsys_JsHttpRequest_Php("utf-8");

$query = $_REQUEST["qu"]; //the query string (what to search for)

/*
Now you must form output data. You can ask your database for that. If so, the code might be like this (example with MySQL full text search):
==============
$out = array();
$sql = "SELECT DISTINCT `title`, MATCH (`title`) AGAINST ('" . mysql_escape_string($query) . "' IN BOOLEAN MODE) AS relevancy
        FROM `some_table`
        WHERE MATCH (`title`) AGAINST ('" . mysql_escape_string($query) . "' IN BOOLEAN MODE)
        ORDER BY `title`
        LIMIT 5";
$res = mysql_query ($sql)
    or die ("Invalid query");
if(mysql_num_rows($res) > 0)
{
  while ($row = mysql_fetch_assoc ($result))
  {
    $out[$row["title"]] = $row["relevancy"];
  }
}
==============

The string part has been chosen as key of array items because the numeric value can mean the relevance of search pattern (take a look at SQL above), and that's why the relevance value can be not unique.
*/

// dummy array, just for example
$out =   array(
    $_REQUEST["qu"] . " in Ukraine"=>1,
    $_REQUEST["qu"] . " top10"=>20,
    $_REQUEST["qu"] . " optimizer"=>4,
    $_REQUEST["qu"] . " is cool"=> 10,
    $_REQUEST["qu"] . " Sevastopol fun club"=>5);

$_RESULT=array("text"=> $out); //output back to client (isn't too tricky? :] )
?>
Return current item: Suggester