Table of Contents
仿百度搜索输入框提示JS代码(基于jquery.autocomplete.js插件)
回复讨论(解决方案)
Home Backend Development PHP Tutorial 仿百度提示框的问题

仿百度提示框的问题

Jun 23, 2016 pm 02:12 PM

输入其它字符都能正常显示
就是输入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 id="仿百度搜索输入框提示JS代码-基于jquery-autocomplete-js插件">仿百度搜索输入框提示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>
Copy after login



回复讨论(解决方案)

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";}}}
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey Announcement of 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

Announcement of 2025 PHP Situation Survey

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

See all articles