Php+ajax do imitation Baidu search dropdown automatic prompt box (there are instances) _php instance
Last Update:2016-06-07
Source: Internet
Author: User
Php+mysql+ajax implementation Baidu Search drop-down prompt box mainly has 3 files three files in the same directory as
Here are three files of the code to import the SQL file into the MySQL database to modify the database password for their own remember OH is UTF-8 encoded
Php+mysql+ajax implement Baidu Search drop-down Prompt box
rpc.php file
Copy Code The code is as follows:
mysql_connect (' localhost ', ' root ', ');
mysql_select_db ("test");
$queryString = $_post[' queryString ');
if (strlen ($queryString) >0) {
$sql = "Select value from countries WHERE value is like '". $queryString. " % ' LIMIT 10 ';
$query = mysql_query ($sql);
while ($result = Mysql_fetch_array ($query, Mysql_both)) {
$value = $result [' value '];
Echo '
'. $value. ' ';
}
}
?>
index.htm file
Copy Code The code is as follows:
<title>Ajax Auto Suggest</title>
SQL database Autocomplete.sql file (import to MySQL)
Copy Code The code is as follows:
--PhpMyAdmin SQL Dump
--Version 3.3.5
--Http://www.phpmyadmin.net
--
--Host: localhost
--Date of generation: December 09, 2010 02:36
--Server version: 5.0.22
--PHP version: 5.2.14
SET sql_mode= "No_auto_value_on_zero";
--
--Database: ' Test '
--
-- --------------------------------------------------------
--
--The structure of the table ' countries '
--
CREATE TABLE IF not EXISTS ' countries ' (
' ID ' int (6) not NULL auto_increment,
' Value ' varchar (+) not NULL default ' ',
PRIMARY KEY (' id ')
) Engine=myisam DEFAULT charset=latin1 auto_increment=243;
--
--Dump the data in the table ' 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 '),
(Ten, ' Antigua and Barbuda '),
(One, ' Argentina '),
(The ' Armenia '),
(' Aruba '),
(+, ' Australia '),
("Austria"),
(+, ' Azerbaijan '),
(+, ' Bahamas '),
(The ' Bahrain '),
(+, ' Bangladesh '),
(The ' Barbados '),
(+, ' Belarus '),
(The ' Belgium '),
(at Belize '),
(' Benin '),
(+, ' Bermuda '),
(+, ' Bhutan '),
("Bolivia"),
(Bosnia and Herzegovina '),
(The ' Botswana '),
(The ' Bouvet Island '),
(+, ' Brazil '),
(+, ' British Indian Ocean territory '),
(Brunei Darussalam '),
("Bulgaria"),
(' Burkina Faso '),
("Burundi"),
(PNS, ' Cambodia '),
(+, ' Cameroon '),
(Canada '),
(+, ' Cape Verde '),
(Cayman Islands '),
(African, ' Central Republic '),
(+, ' Chad '),
("Chile"),
(*, ' China '),
(The "Christmas Island"),
(Cocos (Keeling) Islands '),
("Colombia"),
("Comoros"),
(' Congo '),
(Wuyi, ' Congo '),
(Democratic Republic '),
(Islands, ' Cook '),
(Si, ' Costa Rica '),
(Ivory Coast (Ivory Coast)),
("Croatia (Hrvatska)"),
("Cuba"),
("Cyprus"),
(Czech Republic '),
(The ' Denmark '),
("Djibouti"),
("Dominica"),
(Dominican Republic '),
(+, ' East Timor '),
("Ecuador"),
(the "Egypt"),
(' El Salvador '),
(Equatorial Guinea '),
("Eritrea"),
(+, ' Estonia '),
("Ethiopia"),
(Falkland Islands '),
(Faroe Islands '),
(the "Fiji"),
("Finland"),
("France"),
(French Guiana '),
(French Polynesia '),
(French, ' Southern territories '),
("Gabon"),
(Bayi, ' Gambia '),
("Georgia"),
(the "Germany"),
(+, ' Ghana '),
(Gibraltar '),
(the "Greece"),
("Greenland"),
("Grenada"),
("Guadeloupe"),
("Guam"),
(the "Guatemala"),
(the "Guinea"),
("Guinea-Bissau"),
(94, ' Guyana '),
("Haiti"),
("Heard and McDonald Islands"),
("Honduras"),
(98, ' Hong Kong '),
("Hungary"),
(+, ' Iceland '),
(101, ' India '),
(102, ' Indonesia '),
(103, ' Iran '),
(104, ' Iraq '),
("Ireland"),
(106, ' Israel '),
(107, ' Italy '),
(108, ' Jamaica '),
(109, ' Japan '),
("Jordan"),
(111, ' Kazakhstan '),
("Kenya"),
(113, ' Kiribati '),
("Korea (North)"),
(Korea, ' South '),
("Kuwait"),
(117, ' Kyrgyzstan '),
(118, ' Lao people ' s Democratic Republic '),
(119, ' Latvia '),
(+, ' Lebanon '),
(121, ' Lesotho '),
(122, ' Liberia '),
(123, ' Libyan Arab Jamahiriya '),
(124, ' Liechtenstein '),
(the "Lithuania"),
(126, ' Luxembourg '),
(127, ' Macao '),
(Macedonia '),
(129, ' Madagascar '),
(' Malawi '),
(131, ' Malaysia '),
("Maldives"),
(133, ' Mali '),
(134, ' Malta '),
(135, ' Marshall Islands '),
(136, ' Martinique '),
(137, ' Mauritania '),
(138, ' Mauritius '),
(139, ' Mayotte '),
("Mexico"),
(141, ' Micronesia '),
(142, ' Moldova '),
(143, ' Monaco '),
(144, ' Mongolia '),
(145, ' Montserrat '),
(146, ' Morocco '),
(147, ' Mozambique '),
(148, ' Myanmar '),
(149, ' Namibia '),
("Nauru"),
(151, ' Nepal '),
("Netherlands"),
(153, ' Netherlands Antilles '),
(154, ' New Caledonia '),
(155, ' New Zealand '),
(156, ' Nicaragua '),
(157, ' Niger '),
(158, ' Nigeria '),
(159, ' Niue '),
("Norfolk Island"),
(161, ' Northern Mariana Islands '),
(162, ' Norway '),
(163, ' Oman '),
(164, ' Pakistan '),
(165, ' Palau '),
(166, ' Palestinian territories '),
(167, ' Panama '),
(168, ' Papua New Guinea '),
(169, ' Paraguay '),
("Peru"),
(171, ' Philippines '),
(172, ' Pitcairn '),
(173, ' Poland '),
(174, ' Portugal '),
(175, ' Puerto Rico '),
(176, ' Qatar '),
(177, ' runion '),
(178, ' Romania '),
(179, ' Russian Federation '),
(the "Rwanda"),
(181, ' Saint Helena '),
(182, ' Saint Kitts and Nevis '),
(183, ' Saint Lucia '),
(184, ' Saint Pierre and Miquelon '),
(185, ' Saint Vincent and the Grenadines '),
(186, ' Samoa '),
(187, ' San Marino '),
(188, ' Sao Tome and Principe '),
(189, ' Saudi Arabia '),
("Senegal"),
(191, ' Serbia and Montenegro '),
(192, ' Seychelles '),
(193, ' Sierra Leone '),
(194, ' Singapore '),
(195, ' Slovakia '),
(196, ' Slovenia '),
(197, ' Solomon Islands '),
(198, ' Somalia '),
(199, ' South Africa '),
($, ' South Georgia and the South Sandwich Islands '),
(201, ' Spain '),
(202, ' Sri Lanka '),
(203, ' Sudan '),
(204, ' Suriname '),
(205, ' Svalbard and Jan Mayen Islands '),
(206, ' Swaziland '),
(207, ' Sweden '),
(208, ' Switzerland '),
(209, ' Syria '),
("Taiwan"),
(211, ' Tajikistan '),
(212, ' Tanzania '),
(213, ' Thailand '),
(214, ' Togo '),
(215, ' Tokelau '),
(216, ' Tonga '),
(217, ' Trinidad and Tobago '),
(218, ' Tunisia '),
(219, ' Turkey '),
("Turkmenistan"),
(221, ' Turks and Caicos Islands '),
(222, ' Tuvalu '),
(223, ' Uganda '),
(224, ' Ukraine '),
(225, ' Arab Emirates '),
(226, ' Kingdom '),
(227, ' states of America '),
(228, ' Uruguay '),
(229, ' Uzbekistan '),
("Vanuatu"),
(231, ' Vatican City '),
(232, ' Venezuela '),
(233, ' Vietnam '),
(234, ' Virgin Islands (British) '),
(235, ' Virgin Islands (US) '),
(236, ' Wallis and Futuna Islands '),
(237, ' Western Sahara '),
(238, ' Yemen '),
(239, ' Zaire '),
("Zambia"),
(241, ' Zimbabwe ');
You must be very strong in the local server test, and the principle is simple, not so troublesome.