我已经制作了 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/