我从redis取了几十条数据,加个删除选项删除一条数据,怎么做?

解决方案 »

  1.   

    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>测试工具</title>
    </head>
    <body>
    <form action="" method="get">
        Session:
        <input type="text" name="username"> <br>
        <input type="submit" value="登录" name="subl">
        <div><?php
            if (isset($_GET['username'])) {
                    header("Content-Type:text/html;charset=utf-8");
                    $username = $_GET['username'];
                    $redis = new Redis();
                    $redis->connect('127.0.0.1', 6379);
                    $redis->auth('[email protected]');                $redis->select(4);
                    $k = $redis->keys('session:' . "*");                if (in_array('session:' . $username, $k)) {
                        echo '你已登录';                    $redis->select(2);
                        $redis->geoadd('OrderGeoTree', '121.48012429475784302', '31.23359327436177324', '0');
                        $redis->geoadd('OrderGeoTree', '0.00000268220901489', '0.00000126736058093', '1');
                        $redis->geoadd('OrderGeoTree', '117.20841675996780396', '39.11611222593375459', '110');
                        $redis->geoadd('OrderGeoTree', '128.47578432480124209', '23.48359327436177324', '11');
                        $redis->geoadd('OrderGeoTree', '29.48012446575784302', '19.23359327773244361', '5');
                        $it=NULL;
                        $keyArr = $redis->zScan('OrderGeoTree', $it);
                        print_r($keyArr);
                        echo '<hr>';
    //                    echo "<tr><td>帮忙</td><td>解决</td></tr>";
                        for ($i=0; $i < 140; $i++) {
                            $k = $redis->geopos('OrderGeoTree', $i);
                            print_r($i);
                            print_r($k);                        $v = $i;
                            ?>
                            <form action="" method="get">
                                <input type="submit" value="删除" name="delid">
    <!--                            --><?php //zRem($v); ?>
                            </form>
                            <?php
                        }
                    } else {
                        echo 'Seesion有误!';
                    }        } else {
                echo '还未登录!';
            }       ?>
    </form></body>
    </html>
    <?php
    function zRem($v)
    {
    if (isset($v)) {
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $redis->auth('[email protected]');    $redis->select(2);
        $redis->zRem('OrderGeoTree', $v);
    }
    }