PHPを使用してWordpressでSql配列に値を設定する際に問題が発生しています。Jquery SQL配列ワードプレス
私はここでsearch.htmlの
<form action="" method="post">
<input type="text" placeholder="Name" id="customerAutocomplte" class="ui-autocomplete-input" autocomplete="on" />
</form>
<script src="js/jquery.ui.autocomplete.html.js" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$.noConflict();
$(document).ready(function($){
$('#customerAutocomplte').autocomplete({
source:'suggest_name.php',
minLength:2
});
});
</script>
</head>
を持っているとはsuggest_name.php
/* 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();
私のSQLテーブルである
"人物"
4列があります
"FIRST_NAME"、 "LAST_NAME"、 "電子メール" および "customer_code"
は "Customer_code" は "AI" の主キーです。私の問題は、検索は自動入力や配列の入力ではなく、SQLデータベースにはエントリが含まれていることです。ありがとうございます。