码迷,mamicode.com
首页 > 其他好文 > 详细

关键词查询

时间:2016-11-13 09:31:21      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:url   head   common   success   处理   java   xmlns   sql   页面   

效果如下:

技术分享

技术分享
<!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>
<script src="jquery-1.11.2.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
    <div style="width:200px; height:35px; border:2px solid #60f">
        <input style="width:196px; height:31px;" type="text" id="name" />
    </div>
    <div id="list" style="width:200px; height:500px; border:2px solid #60f
    "></div>
    <script type="text/javascript">
        $("#name").keyup(function(){
                var n=$(this).val();
                if(n!="")
                {
                    $.ajax({
                            url:"listchuli.php",
                            data:{n:n},
                            type:"POST",
                            dataType:"TEXT",
                            success: function(data){
                                    var sz=data.split("|");
                                    var str="";
                                    for(var i=0;i<sz.length;i++){
                                            str=str+"<div class=‘1‘>"+sz[i]+"</div>";
                                        }
                                        $("#list").html(str);
                                }
                                
                        });
                    }
                    else{
                            $("#list").html("");
                        }
            });
    </script>
</body>
</html>
技术分享

2.处理页面

技术分享
<?php
$name = $_POST["n"];

include("./lei/AAA.class.php");
$db = new AAA();

$sql = "select name from info where name like ‘%{$name}%‘ ";

echo $db->StrQuery($sql);
技术分享

关键词查询

标签:url   head   common   success   处理   java   xmlns   sql   页面   

原文地址:http://www.cnblogs.com/ysdong/p/6058109.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!