Heim >Backend-Entwicklung >PHP-Tutorial >仿百度提示框的问题

仿百度提示框的问题

WBOY
WBOYOriginal
2016-06-23 14:12:08794Durchsuche

输入其它字符都能正常显示
就是输入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";}}}

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn