php - 如何通过php设置链接url?

标签 php

我已经制作了 14 个 url 链接。我有一个问题,当我按下链接 2 它返回 1 并且所有剩余的链接返回递减到原始值。例如,当我按 3 时,它返回 2。当我按 4 时,它返回 3,依此类推。我想知道为什么会这样。
这是代码

<html>
    <body>
    <head>
        <title>Paging</title>
        <style>

            #numberDiv
            {
                display: inline-block;
                border: 1px solid black;
                width: 35px;
                height: 35px;
                margin-left: 0.01px;
                background-color: aliceblue;
            }
        </style>
    </head>
    <?php
    if (isset($_GET["id"]))
    {
        $id=$_GET["id"];
        echo $id;
        echo "<br>";
    }
    $a=14;
    $b=1;
    $c=1;
    for ($b = 1; $b <= $a; $b++) {

        ?><a href="zain.php?id=<?php echo $c; ?>" style="text-decoration: none; text-align: center;color: black;font-size: x-large">
        <?php

        $c=$b;
        echo "<div id='numberDiv'>" . $c . "</div>" ?></a><?php
    }

    ?>


    </body>
    </html>

最佳答案

使用以下代码。它会为你工作

<html>
<body>
<head>
    <title>Paging</title>
    <style>

        #numberDiv
        {
            display: inline-block;
            border: 1px solid black;
            width: 35px;
            height: 35px;
            margin-left: 0.01px;
            background-color: aliceblue;
        }
    </style>
</head>
<?php
if (isset($_GET["id"]))
{
    $id=$_GET["id"];
    echo $id;
    echo "<br>";
}
$a=14;
$b=1;
$c=1;
for ($b = 1; $b <= $a; $b++) {
     $c=$b;
    ?><a href="zain.php?id=<?php echo $c; ?>" style="text-decoration: none; text-align: center;color: black;font-size: x-large">
    <?php

    echo "<div id='numberDiv'>" . $c . "</div>" ?></a><?php
}

?>


</body>
</html>

关于php - 如何通过php设置链接url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34564592/

相关文章:

javascript - 使用 JQuery 从数组中设置选择选项值和文本

php - 为 WooCommerce 中销售的产品启用免费送货

php - 包含内联大括号错误的 Smarty 模板

php - 使用 AJAX 和 PHP 检查电子邮件地址是否存在

php - 缺少 Google API autoload.php

javascript - 如何将外部 PHP 文件包含到 Joomla 文章中?

javascript 'if' 未从 ajax 捕获 null

php - 拉维尔 5 : how can I retrieve and display all posts that belong to certain category

Php 用 str_replace 清理双破折号

php - 简单的模组重写