0
我已經編寫了一個代碼來登錄一個用戶並顯示他的各種詳細信息。這工作得很好。除此之外;我添加了一個似乎無法工作的自動完成搜索。我正在使用Jquery的自動完成功能。搜索框中的字段是從SQL中搜索的。PHP-SQl自動填充搜索
但沒有任何反應。我在文本字段中鍵入文本,但沒有任何反應。
這裏是我的全部修正PHP代碼(不含連接文件)
<script>
$(document).ready(function() {
$("input#autocomplete").autocomplete({
source: keywordList,
minLength: 1,
});
});
</script>
<?php echo keywordArray(); ?>
<?php function keywordArray()
{
$rsKeywords = mysql_query("SELECT * FROM job");
$output = '<script>'."\n";
$output .= 'var keywordList = [';
while($row_rsKeywords = mysql_fetch_assoc($rsKeywords))
{
$output .= '"'.$row_rsKeywords['work'].'",';
}
$output = substr($output,0,-1); //Get rid of the trailing comma
$output .= '];'."\n";
$output .= '</script>';
return $output;
}
?>
//搜索腳本:
<?php
if(!isset($_POST['submit'])){
echo "Your search was invalid";
exit;
}
$keyword = mysql_real_escape_string($_POST['keywords']);
$sql = "SELECT * FROM job WHERE work='$keyword' or work LIKE 'ANOTHER_PARAMETER' LIMIT 5";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
echo //details etc
>?
對不起,但那也沒有回答我的問題。 – xan
嘗試以適當的方式編寫您的問題。嘗試解釋發生了什麼,例如。 – HBv6
哦,那個。什麼都沒發生。沒有錯誤。我在文本字段中寫了一些東西。沒有任何反應。等待我只編輯我的問題。 – xan