我正在嘗試使用AJAX autocompletes,並且遇到了使兩種語言協同工作的幾個問題。帶有多個參數的PHP isset()
當我更換所有隻有1 $ _ POST的issets的片段下方會工作,但是通過添加另一個$ _ POST我得到第5行
<?php
require_once '../Configuration.php';
if (isset($_POST['search_term'] . $_POST['postcode']) == true && empty ($_POST['search_term'] . $_POST['postcode']) == false) {
$search_term = mysql_real_escape_string($_POST['search_term'] . $_POST['postcode']);
$query = mysql_query("SELECT `customer_name`,`postcode` FROM `Customers` WHERE `customer_name` LIKE '$search_term%' ");
while(($row = mysql_fetch_assoc($query)) !== false) {
//loop
echo '<li>',$row['customer_name'] . $row['postcode'] '</li>';
}
}
?>
爲什麼它拋出這個任何意見錯誤錯誤將不勝感激。謝謝。
我明白我應該使用mysqli的,我只是試圖讓邏輯首先:)
JS:
Primary.js:
$(document).ready(function() {
$('.autosuggest').keyup(function() {
var search_term = $(this).attr('value');
var postcode = $_GET['postcode'];
//alert(search_term); takes what is typed in the input and alerts it
$.post('ajax/search.php', {search_term:search_term, postcode:postcode}, function (data) {
$('.result').html(data);
$('.result li').click(function() {
var result_value = $(this).text();
$('.autosuggest').attr('value', result_value);
$('.result').html('');
});
});
});
});
一個'isset'。順便說一句'isset == true'是多餘的。 – dualed