五 根据用户名和手机号进行查询操作

点击查询按钮后会跳转新页面,显示用户信息

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户信息后台管理系统</title>
</head>
<style type="text/css">
    .wrapper {width: 1000px;margin: 20px auto;}
    h2 {text-align: center;}
    .return {margin-bottom: 20px;}
    .return a {text-decoration: none;color: #fff;background-color: green;padding: 6px;border-radius: 5px;}
    td {text-align: center;}
</style>
<body>
<div class="wrapper">
    <h2>查询结果</h2>
    <div class="return">
        <a href="search7.php" >返回</a>
    </div>
    <!--表格信息-->
    <table width="960" border="1" align =''>
        <tr>
            <th>姓名</th>
            <th>性别</th>
            <th>爱好</th>
            <th>手机号</th>
            <th>邮箱</th>
            <th>头像</th>
            <th>备注</th>
            <th>id</th>
            <th>删除</th>
            <th>修改</th>
        </tr>

        <!--用php连接数据库并显示查询结果-->
        <?php
        header('content-type:text/html; charset=utf-8');
        $mysqli = mysqli_connect('localhost','root','3589216','php10');
        mysqli_query($mysqli,"set names 'utf8'");
        if (!$mysqli) {
            printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
            exit;
        }

        $info = $_POST["info"];
        mysqli_query($mysqli , "set names utf8");
        //数据库中的字段名是 name1 和 mobile
        $sql = "select * from msg where name1 ='{$info}'or mobile = '{$info}'  ";
        $retval = mysqli_query( $mysqli, $sql );

        while($row = mysqli_fetch_array($retval)) {
            echo "<tr>
                     <td> {$row['name1']}</td> " .
                    "<td>{$row['sex']} </td> " .
                    "<td>{$row['interest']} </td> " .
                    "<td>{$row['mobile']} </td> " .
                    "<td>{$row['email']} </td> " .
                    "<td>{$row['files']} </td> " .
                    "<td>{$row['remark']} </td> ".
                    "<td>{$row['id']} </td> ".
                    "<td><a href='javascript:del({$row['id']})'>删除</a> </td>".
//弹窗确定<script>标签
                    "<td><a href='change.php?id={$row['id']}'>修改</a> </td>   
//连接到change.php
                   </tr>";
        }
        ?>
    </table>
</div>
</body>
<!--要删除时的提示-->
<script type="text/javascript">
    function del (id) {
        if (confirm("确定删除这条信息吗?")){
            window.location = "delete.php?id="+id;  /*连接到delete.php --> 连接数据库 --> 删除*/
        }
    }
</html>

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值