jquery autocomplete 代码:
以下代码里面的搜索是写死的,我想根据输入的内容去到数据库里面查询,数据库是 mysql 的,开发环境是php
nbsp;html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script></script>
<script></script>
<script> <br /> var websites = [ <br /> "上海","海浪", "北京", "广州", "Sogou", "Baidu", "Tencent", <br /> "Taobao", "Tom", "Yahoo", "JavaEye", "Csdn", "Alipay" <br /> ]; <br /> $().ready(function() { <br /> $("#website").autocomplete(websites); <br /> }); <br /> <br /> </script>
<script> <br /> $().ready(function() { <br /> <br /> function findValueCallback(event, data, formatted) { <br /> $("#content").html("<strong>"+(!data ? "No match!" : "Selected: " + formatted)+""); <br /> } <br /> <br /> $("#website").autocomplete(websites,{ <br /> minChars: 0, <br /> max: 5, <br /> autoFill: true, <br /> mustMatch: true, <br /> matchContains: true, <br /> scrollHeight: 220, <br /> formatItem: function(data, i, total) { <br /> return "<I>"+data[0]+""; <br /> }, <br /> formatMatch: function(data, i, total) { <br /> return data[0]; <br /> }, <br /> formatResult: function(data) { <br /> return data[0]; <br /> } <br /> }); <br /> $("#website").result(findValueCallback); <br /> $("#getvalue").click(function() {$("#website").search()}); <br /> }); <br /> </script>
我将
js 里面的websites 写成了 我后台的路径,还是不行。
<script> <br /> $().ready(function() { <br /> $("#website").autocomplete('search.php?website='website); <br /> }); <br /> </script>
search.php
$conn= mysql_connect('localhost', 'root', '123456') or die("数据库连接出错了"); //连接数据库
mysql_query("set names 'utf8' ");//设置编码输出
mysql_select_db('test'); //选择数据库
?>
$q=strtolower($_GET["website"]);
$sql="select * from art where title like '%$q%' limit 0,10";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
$city[]=$row;
}
?>
?>
回复讨论(解决方案)
求 急急急急急急急急
来个大神级的人物,指点下江山
http://www.markdream.com/code/phpjqueryui%E5%AE%9E%E7%8E%B0%E8%87%AA%E5%8A%A8%E5%AE%8C%E6%88%90%E6%8F%90%E7%A4%BA.shtml
http://blog.sina.com.cn/s/blog_6925792f0100kng9.html
你看下吧,要是再不行,真帮不了你。
码无边,兄弟,太感谢了。可以实现效果。。 给分。。。。

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
