我已经制作了14个网址链接。我有问题,当我按下链接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>
答案 0 :(得分:2)
使用以下代码。它适合你
<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>