码迷,mamicode.com
首页 > Web开发 > 详细

使用ajax进行汽车详情表的查询

时间:2016-06-26 23:55:56      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

主界面代码

<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>汽车详情表</title>
    <script type="text/javascript" src="0621popwindow/jquery-1.11.2.min.js"></script>
    <script src="0621popwindow/tanchuang.js"></script>
    <link href="0621popwindow/tanchuang.css" rel="stylesheet" type="text/css" />

</head>

<body>
<table width="100%" border="2" cellpadding="0" cellspacing="1">
    <tr>

    <td>名称</td>
    <td>类型</td>
    <td>时间</td>
    <td>操作</td>

    </tr>
    <?PHP
    include("DBDA.class.php");
    $db=new DBDA();

    $sql="select * from car";
    $re=$db->query($sql);
    foreach ($re as $v)
    {
        echo "
        <tr>
        <td>{$v[1]}</td>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td><input type=‘button‘ value=‘查看详情‘ code=‘{$v[0]}‘ class=‘anniu‘></td>
</tr>
        ";
    }
    ?>
</table>

</body>
<script type="text/javascript">
$(document).ready(function(e){
    $(".anniu").click(function(){
        var code = $(this).attr("code");
        alert(code);z
        $.ajax({
            url:"0624carchuli.php",
            data:{code:code},
            type:"POST",
            dataType:"TEXT",
            success:function(data){
                alert(data);

                var lie=data.split("^");

                var html = "<div class=‘xq‘>代号:"+lie[0]+"</div><div class=‘xq‘>名称:"+lie[1]+"</div><div class=‘xq‘>系列:"+lie[2]+"</div><div class=‘xq‘>上市时间:"+lie[3]+"</div><div class=‘xq‘>油耗:"+lie[4]+"</div><div class=‘xq‘>功率:"+lie[5]+"</div><div class=‘xq‘>排量:"+lie[6]+"</div><div class=‘xq‘>价格:"+lie[7]+"</div>";
                var win = new Window({

                    width : 300, //宽度
                    height : 400, //高度
                    title : ‘汽车详情信息‘, //标题
                    content : html, //内容
                    isMask : true, //是否遮罩
                    //buttons : button, //按钮
                    isDrag:true,//是否移动
                });
            }
        })
    })
})


</script>
</html>

  

 

 处理界面代码

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/6/24
 * Time: 20:37
 */

$code=$_POST["code"];

include("DBDA.class.php");
$db=new DBDA();

$sql="select * from car where code=‘{$code}‘";

$re=$db->query($sql);

echo implode("^",$re[0]);

  

使用ajax进行汽车详情表的查询

标签:

原文地址:http://www.cnblogs.com/pangchunlei/p/5618872.html

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