具有多个参数的 PHP isset()
我正在尝试使用AJAX自动完成,并且在使两种语言协同工作时遇到了一些问题。
当我用1 $_POST替换所有设置时,下面的代码段将起作用,但是通过添加另一个$_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:
主要.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('');
});
});
});
});