0

I am using jQuery Autocomplete 1.8. Every time it returns every string that contains the input as a substring. How can I make it return only the strings that contains the input as a prefix?

1 Answer 1

1

I'm doing it in the sql. I'm using php to generate the json

<?php
set_include_path(get_include_path() . ':' . '/home/lms/library/php');
set_include_path(get_include_path() . ':' . '/home/lms/systems/ORM');
require_once("Configuration.php");
require_once("DALI_Class.php");

//$unitID = $_POST['unitID'];
$unitID = $_GET["term"];
$return_array=array();
$row_array=array();
$lmsAdminSysDB = DALI::connect(LMS_MIDDLEWARE_DATABASE);

$selectUnit = "SELECT " . 
                "UnitID, " . 
                "Title " . 
                "FROM UnitTBL " . 
                "WHERE UnitID LIKE '".$unitID."%' " .                 
                "ORDER BY UnitID " . 
                ""; 

$resultUnit = $lmsAdminSysDB->Execute($selectUnit);

while($row = $resultUnit->FetchRow()) {
   $row_array['label'] = $row['UnitID']." - ".$row['Title'];
   $row_array['value'] = $row['UnitID'];
   $row_array['title'] = $row['Title'];
   array_push($return_array,$row_array);

 }
unset($resultUnit);

//header('Content-type: application/json');
//echo json_encode($result);
DALI::disconnect($lmsAdminSysDB);
echo json_encode($return_array);
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.