使用按钮限制列表

时间:2014-11-04 10:50:48

标签: php

我想打印每个用户的应用程序的最后一次访问,但我想将此列表限制为特定的数字(最终将由用户配置)。 Atm我可以打印所有内容,但我想实现一个按钮,允许显示5个事件,然后它们就会出现。一旦实现,也要做后盾。

但是我现在的代码如下:

        $min = 0;
        if(count($time) > 5)
        {
            $aux = 5;
        }
        else
        {
            $aux = count($time);
        }

        if(isset($_POST['button']))
        {
            if((count($time) - $aux) > 5)
            {
                $aux = aux + 5;
                $min = $min + 5;
            }
            else
            {
                $aux = count($time);
                if(count($time) > 5)
                {
                    $min = count($time) - 5;
                }
            }

        }

        for($i = $min ; $i<$aux; $i++)
        {
            echo '<br>'.($i+1).'. '.date('Y-m-d H:i:s', $time[$i]['time_stamp'])."\t".' por '.$ips['ip'].'<br>';
        }

        ?>

        <input name="button" type="button" id="button" onclick="access.func.php" value=">>" />

我似乎无法更新表格,主要是因为我认为按钮没有被正确调用。

编辑:更改了字形错误。

EDIT2:$ count已更改为count($ time)

2 个答案:

答案 0 :(得分:1)

首先,您的代码中存在拼写错误。

 $axu = aux + 5;

将其更改为$aux = $aux + 5;,然后查看。

编辑:

input button放在<form>这样的地方:

<form action="access.func.php" method="post">
    <input name="button" type="submit" id="button" value=">>" />
</form>

答案 1 :(得分:1)

可能的拼写错误axu = aux?

$axu = aux + 5;

if((count($time) - $aux) > 5)
        {
            $aux= $aux + 5;
            $min = $min + 5;
        }

如果它的意图拼写错误(axu) - 我认为它不符合提供的代码: - &gt;只需将$添加到辅助

if((count($time) - $aux) > 5)
            {
                $axu = $aux + 5;
                $min = $min + 5;
            }