$r = mysql_fetch_array(mysql_query(select count(*) from .. where IP='$_SERVER[REMOTE_ADDR]'));include($r[0].".htm");

解决方案 »

  1.   

    我的代码!但是还是有点问题.没有达到效果,请哪位修改下:<?php $Conn = new mysqli("数据库地址", "用户名", "口令", "库名称");
    if (mysqli_connect_errno()) exit("数据库联结失败!");
    $thisTime=TO_DAYS(now())
    $ip=$_SERVER['REMOTE_ADDR']$Sql = "SELECT * FROM log WHERE ip =$ip;$rt = $Conn -> query($Sql); 
    if ($rt -> num_rows > 0) {
    $rs = $rt -> fetch_assoc(); 
            $iniLog=$rs['logtime'];
            $hit = $rs['operation'] + 1; 
            $dtime=TO_DAYS(NOW()) - TO_DAYS(logtime);
            unset($rs);
            if $dtime>0 { $Conn -> query("update log set logtime=$thisTime,operation = 1 where ip = $ip);
            header("Location: " '01.htm');
    }
            else{ if $hit<=10 { $Conn -> query("update log set operation = $hit where ip = $ip);
            header("Location: " . ($hit < 10 ? "0$hit" : $hit) . '.htm');
                   else {header("Location:" 'end.htm');}
             }
    else {
    $hit = 1; $Conn -> query("insert into log (ip, logtime, operation) values ('" . $_SERVER['REMOTE_ADDR'] . "', '" . date("Y-m-d H:i:s") . "', 1)");
    }
    $rt -> free(); unset($rt); $Conn -> close(); unset($Conn);
    ?> **********************或者***********************
    <?php $Conn = new mysqli("localhost", "p0_216447", "123456789", "mysql");
    if (mysqli_connect_errno()) exit("数据库联结失败!");
    $Sql = "SELECT * FROM log WHERE IP = '" . $_SERVER['REMOTE_ADDR'] . "' AND TO_DAYS(NOW()) - TO_DAYS(logtime) = 0";
    $rt = $Conn -> query($Sql); if ($rt -> num_rows > 0) {
    $rs = $rt -> fetch_assoc(); $hit = $rs['operation'] + 1; unset($rs);
    $Conn -> query("UPDATE log SET operation = $hit WHERE IP = '" . $_SERVER['REMOTE_ADDR'] . "' AND TO_DAYS(NOW()) - TO_DAYS(logtime) = 0");
    }
    else {
    $hit = 1; $Conn -> query("INSERT INTO log (IP, logtime, operation) VALUSE ('" . $_SERVER['REMOTE_ADDR'] . "', '" . date("Y-m-d H:i:s") . "', 1)");
    }
    $rt -> free(); unset($rt); $Conn -> close(); unset($Conn);
    if ($hit > 10) $hit = 10;
    header("Location: " . ($hit < 10 ? "0$hit" : $hit) . '.htm');
    ?> 
    请哪位修改下,谢谢!!!