0

我正在使用 jQuery 自动完成 1.8。每次它返回每个包含输入作为子字符串的字符串。我怎样才能让它只返回包含输入作为前缀的字符串?

4

1 回答 1

1

我在sql中做。我正在使用 php 生成 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);
?>
于 2011-02-01T05:13:56.093 回答