当前位置: 网学 > 编程文档 > PHP > 正文

php+ajax做仿百度搜索下拉自动提示框(有实例)

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/20

鉴于大家对PHP十分关注,我们编辑小组在此为大家搜集整理了“php+ajax做仿百度搜索下拉自动提示框(有实例)”一文,供大家参考学习!

php+mysql+ajax实现百度搜索下拉提示框 主要有3个文件三个文件在同一个目录里 如下图
php+mysql+ajax实现百度搜索下拉提示框
下面是三个文件的代码 把sql文件导入到mysql数据库里 修改下数据库密码为自己的 记得哦是UTF-8编码

php+mysql+ajax实现百度搜索下拉提示框
效果图
php+mysql+ajax实现百度搜索下拉提示框
rpc.php文件
复制代码 代码如下:
<?php
mysql_connect(''localhost'', ''root'' ,'''');
mysql_select_db("test");
$queryString = php+ajax做仿百度搜索下拉自动提示框(有实例)_网学
浏览:
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号
POST[''queryString''];
if(strlen($queryString) >0) {
$sql= "SELECT value FROM countries WHERE value LIKE ''".$queryString."%'' LIMIT 10";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query,MYSQL_BOTH)){
$value=$result[''value''];
echo ''<li onClick="fill(\''''.$value.''\'');">''.$value.''</li>'';
}
}
?>

index.htm文件
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/uploadfile/201306/20/F9165939519.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
<div class="suggestionList" id="autoSuggestionsList">

</div>
</div>
</form>
</div>
</body>
</html>

sql数据库autoComplete.sql文件(导入到mysql)
复制代码 代码如下:
-- phpMyAdmin SQL Dump
-- version 3.3.5
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2010 年 12 月 09 日 02:36
-- 服务器版本: 5.0.22
-- PHP 版本: 5.2.14
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- 数据库: `test`
--
-- --------------------------------------------------------
--
-- 表的结构 `countries`
--
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(6) NOT NULL auto_increment,
`value` varchar(250) NOT NULL default '''',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=243 ;
--
-- 转存表中的数据 `countries`
--
INSERT INTO `countries` (`id`, `value`) VALUES
(1, ''Afghanistan''),
(2, ''Aringland Islands''),
(3, ''Albania''),
(4, ''Algeria''),
(5, ''American Samoa''),
(6, ''Andorra''),
(7, ''Angola''),
(8, ''Anguilla''),
(9, ''Antarctica''),
(10, ''Antigua and Barbuda''),
(11, ''Argentina''),
(12, ''Armenia''),
(13, ''Aruba''),
(14, ''Australia''),
(15, ''Austria''),
(16, ''Azerbaijan''),
(17, ''Bahamas''),
(18, ''Bahrain''),
(19, ''Bangladesh''),
(20, ''Barbados''),
(21, ''Belarus''),
(22, ''Belgium''),
(23, ''Belize''),
(24, ''Benin''),
(25, ''Bermuda''),
(26, ''Bhutan''),
(27, ''Bolivia''),
(28, ''Bosnia and Herzegovina''),
(29, ''Botswana''),
(30, ''Bouvet Island''),
(31, ''Brazil''),
(32, ''British Indian Ocean territory''),
(33, ''Brunei Darussalam''),
(34, ''Bulgaria''),
(35, ''Burkina Faso''),
(36, ''Burundi''),
(37, ''Cambodia''),
(38, ''Cameroon''),
(39, ''Canada''),
(40, ''Cape Verde''),
(41, ''Cayman Islands''),
(42, ''Central African Republic''),
(43, ''Chad''),
(44, ''Chile''),
(45, ''China''),
(46, ''Christmas Island''),
(47, ''Cocos (Keeling) Islands''),
(48, ''Colombia''),
(49, ''Comoros''),
(50, ''Congo''),
(51, ''Congo''),
(52, '' Democratic Republic''),
(53, ''Cook Islands''),
(54, ''Costa Rica''),
(55, ''Ivory Coast (Ivory Coast)''),
(56, ''Croatia (Hrvatska)''),
(57, ''Cuba''),
(58, ''Cyprus''),
(5

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号