首頁  >  文章  >  後端開發  >  仿百度提示框的问题

仿百度提示框的问题

WBOY
WBOY原創
2016-06-23 14:12:08752瀏覽

输入其它字符都能正常显示
就是输入00或000的时候就显示不了,数据库里面有相关的数据
我估计是不是把000当成空值了?请各位大神帮我看看

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=GBK" /><title>仿百度搜索输入框提示JS代码</title><link href="css/jquery.autocomplete.css" type=text/css rel=stylesheet><script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript" src="js/jquery.autocomplete.js"></script><script language="javascript">			$(document).ready(function() {			$("#keyword").autocomplete("getajaxtag.php",			{				delay:10,            	minChars:1,            	matchSubset:1,            	matchContains:1,            	cacheLength:10,            	onItemSelect:selectItem,            	onFindValue:findValue,            	formatItem:formatItem,            	autoFill:false        	}    		);			});			function findValue(li) {    			if( li == null ) return alert("No match!");				if( !!li.extra ) var sValue = li.extra[0];				else var sValue = li.selectValue;				}			function selectItem(li) { findValue(li);}			function formatItem(row) { return row[0];//return row[0] + " (id: " + row[1] + ")"//如果有其他参数调用row[1],对应输出格式Sparta|896			}			function lookupAjax(){			var oSuggest = $("#keyword")[0].autocompleter;			oSuggest.findValue();			return false;			}</script></head><body><div class="sidebarBlock" style="margin:0 auto; text-align:center;">  <h3>仿百度搜索输入框提示JS代码(基于jquery.autocomplete.js插件)</h3>  <form id="formkeyword" name="formkeyword" method="post" action="post.php">    <div class="sidebarSearch">          <input type="text" name="keyword" size="40" maxlength="255" value="" id="keyword" class="text"></input>          <input type="submit" value="搜索" class="button"></input>    </div>  </form></div></body></html>



回复讨论(解决方案)

include_once ('conn.php');$keyword = $_GET ['q'] ;$sql = mysql_query ( "SELECT DISTINCT(item_code) FROM sku_rule WHERE  item_code LIKE '" . $keyword . "%'  LIMIT 0,10" );$myaf = mysql_affected_rows();while ( $value = mysql_fetch_array ( $sql ) ) {	echo $keyword = iconv ( 'utf-8', 'utf-8', $value ['item_code'] ) . "\n";}if($myaf<10){$li=10-$myaf;$sql_sku = mysql_query ( "SELECT DISTINCT(sku) FROM sku_rule WHERE  sku LIKE '" . $keyword . "%'  LIMIT 0,$li" );$myaf_sku = mysql_affected_rows();while ( $value_sku = mysql_fetch_array ( $sql_sku ) ) {	echo $keyword = iconv ( 'utf-8', 'utf-8', $value_sku ['sku'] ) . "\n";}$as=$myaf+$myaf_sku;if($as<10){$as=10-$as;$sql_as = mysql_query ( "SELECT DISTINCT(asin) FROM sku_rule WHERE  asin LIKE '" . $keyword . "%'  LIMIT 0,$as" );while ( $value_as = mysql_fetch_array ( $sql_as ) ) {	echo $keyword = iconv ( 'utf-8', 'utf-8', $value_as ['asin'] ) . "\n";}}}

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn