Php 我无法将值从数据库分配到文本框

Php 我无法将值从数据库分配到文本框,php,jquery,mysql,Php,Jquery,Mysql,我正在做一个搜索操作,即按客户名称搜索客户。我有一个文本框,当在文本上键入首字母时,jquery中有自动完成功能,列出所有与字母匹配的客户名称。我们可以从中选择想要的名称。我想在另一个文本框中从客户表中获取客户id 我的桌子是顾客的 customer id name 1 neenu 2 nitha 3 nisha 4 sitha 我有两个页面payment_verification.php和suggest_field.php <

我正在做一个搜索操作,即按客户名称搜索客户。我有一个文本框,当在文本上键入首字母时,jquery中有自动完成功能,列出所有与字母匹配的客户名称。我们可以从中选择想要的名称。我想在另一个文本框中从客户表中获取客户id

我的桌子是顾客的

customer 

id    name

1      neenu

2      nitha

3      nisha

4       sitha
我有两个页面payment_verification.php和suggest_field.php

 <?php
 require_once("codelibrary/inc/variables.php");
 require_once("codelibrary/inc/functions.php");
 if ( !isset($_REQUEST['term']) )
 exit;
 $field=$_GET['field'];
 $table=$_GET['table'];


 $qry='select distinct '.$field.' from '.$table.'
 where '.$field.' like "'.     mysql_real_escape_string($_REQUEST['term']) .'%"  
 order  by '.$field.' asc';
 $rs = mysql_query($qry);
 $data = array();
 if ( $rs && mysql_num_rows($rs) )
 {
  while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
   {
    $data[] = array(
        'value' => $row[$field]
    );
 }
}
echo json_encode($data);
flush();
 ?>
payment_verification.php

<script>
 function auto(tab,field,id){
 var point='#'+id;
 jQuery(document).ready(function(){
 $(point).autocomplete({source:'suggest_field.php?
 field='+field+'&table='+tab,    minLength:1});
  });
    }


 </script>   

 <input name="cust_name1" id="name" 
 onFocus="auto('customer','name','name')"     type="text" />

 <input name="cust_id" id="cust_id"    type="text"  vale=""/>
在auto函数中,第一个参数是表名,第二个参数是字段名,第三个参数是该文本框的id

建议_field.php

 <?php
 require_once("codelibrary/inc/variables.php");
 require_once("codelibrary/inc/functions.php");
 if ( !isset($_REQUEST['term']) )
 exit;
 $field=$_GET['field'];
 $table=$_GET['table'];


 $qry='select distinct '.$field.' from '.$table.'
 where '.$field.' like "'.     mysql_real_escape_string($_REQUEST['term']) .'%"  
 order  by '.$field.' asc';
 $rs = mysql_query($qry);
 $data = array();
 if ( $rs && mysql_num_rows($rs) )
 {
  while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
   {
    $data[] = array(
        'value' => $row[$field]
    );
 }
}
echo json_encode($data);
flush();
 ?>
我在第一个文本框中获取了客户名称,我想在第二个文本框中获取客户id。
对不起,我的问题有任何误解。

获取客户名称有什么问题?您的查询对sql Injection是开放的,我得到了客户名称,但想得到客户id并将其签名到第二个文本框,该文本框id为cust_ids,因为您使用的是jquery,而不是cuscust_id.val有什么问题?选中此复选框现在查询用于获取客户名称,不获取客户id,,从数据库中获取客户id并将其分配到第二个文本框,这是我的需要