通过在 smarty 框架中定义如下,for 循环无法提供正确的输出

For loop not give proper output by defining as below in smarty framework

有人知道如何在 smarty 模板中使用 for 循环吗?我想定义条件如下。

<?php
        $quer = "select * from users";
        $res1 = $conn->query($quer);
        $count = $res1->num_rows;

        $a = $count/10;
        $a = ceil($a);
            echo "<br/>"; echo "<br/>";

我想在 smarty for 循环中转换下面的 for 循环,这怎么可能?

        for($b=1; $b<=$a ; $b++){ 
                ?><a href="home.php?page=<?php echo $b;?>" style="text-decoration:none;"><?php echo $b." ";?></a><?php
            }

    ?>

代码很简单(放在你的模板文件中):

{for $b=1 to $end}
    <a href="home.php?page={$b}" style="text-decoration:none;">{$b} </a>
{/for}

阅读文档中有关 smarty 循环的更多信息:for, foreach