У меня есть search.html
Код: Выделить всё
$.noConflict();
$(document).ready(function($){
$('#customerAutocomplte').autocomplete({
source:'suggest_name.php',
minLength:2
});
});
Код: Выделить всё
/* Attempt MySQL server connection */
$link = mysqli_connect("localhost", "root", "mysql", "wordpress");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
else {
$link->set_charset('utf8');
}
/* retrieve the search term that autocomplete sends */
$term = trim(strip_tags($_GET['term']));
$a_json = array();
$a_json_row = array();
if ($data = $link->query("SELECT * FROM persons WHERE first_name LIKE '%$term%' OR last_name LIKE '%$term%' ORDER BY first_name , last_name")) {
while($row = mysqli_fetch_array($data)) {
$first_name = htmlentities(stripslashes($row['first_name ']));
$last_name = htmlentities(stripslashes($row['last_name']));
$code = htmlentities(stripslashes($row['customer_code']));
$a_json_row["id"] = $code;
$a_json_row["value"] = $first_name.' '.$last_name;
$a_json_row["label"] = $first_name.' '.$last_name;
array_push($a_json, $a_json_row);
}
}
// jQuery wants JSON data
echo json_encode($a_json);
flush();
"persons"
содержит 4 столбца
"first_name" "last_name" "email" и «код_клиента»
Код_клиента — это первичный ключ «ИИ». Моя проблема в том, что поиск не выполняет автозаполнение и не заполняет массив, НИЧЕГО, база данных sql содержит записи, спасибо.
Подробнее здесь: https://stackoverflow.com/questions/460 ... -wordpress
Мобильная версия