jquery php Baidu search box Smart tips effect _php Tutorial

Source: Internet
Author: User
Tags mysql tutorial
This program is the use of php+ajax+jquery implementation of a imitation Baidu smart hints, the need for friends can download test Oh.

Let's take a look at the effect

The code is as follows

index.html file, Save as Index.htm

The code is as follows Copy Code




Ajax Auto Suggest






PHP file

copy code

!--? php

MySQL tutorial _connect (' Local Host ', ' root ', ' root ');
mysql_select_db ("AutoComplete");

$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. '
  • ';
    }

    }

    ;

    Sql.sql Copy this here to your database tutorial

    The code is as follows Copy Code

    --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";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT =@ @CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS =@ @CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION =@ @COLLATION_CONNECTION */;
    /*!40101 SET NAMES UTF8 */;

    --
    --Database: ' AutoComplete '
    --

    -- --------------------------------------------------------

    --
    --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 ');

    Note: There is a jquery file is not put up, we can go to http://down.php100.com download or Baidu search


    http://www.bkjia.com/PHPjc/444742.html www.bkjia.com true http://www.bkjia.com/PHPjc/444742.html techarticle This program is the use of php+ajax+jquery implementation of a imitation Baidu smart hints, the need for friends can download test Oh. First to see the effect code as follows index.html file, Bao Bao ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.