JQUERY からのオートコンプリートがあり、選択している製品の名前ではなく、製品の ID が必要です。
これは完全な AUTOCOMPLETE です。
<?php
// if the 'term' variable is not sent with the request, exit
if ( !isset($_REQUEST['term']) )
exit;
// connect to the database server and select the appropriate database for use
include 'conexion2.php';
// query the database table for client codes that match 'term'
$rs = mysql_query('SELECT id_cliente, nombrecliente FROM cliente where nombrecliente like "'. mysql_real_escape_string($_REQUEST['term']) .'%" order by nombrecliente asc', $conexio);
// loop through each name returned and format the response for jQuery
$data = array();
if ( $rs && mysql_num_rows($rs) )
{
while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
{
$data[] = array(
'label' => $row['nombrecliente'],
'value' => $row['nombrecliente'],
);
}
}
// jQuery wants JSON data
echo json_encode($data);
flush();
クライアントを選択する際に ID を取り出す方法がわかりません。'value' => $row['id_cliente'] を変更すると、オートコンプリート INPUT で ID 番号が取得されます。