Reputation:
I have made 14 url links. I have problem that when I press link 2 it returns 1 and all of the remaining links return decremented to original value. For example when I press 3 it returns 2. When I press 4 it returns 3 and so on. I want to know why is that.
This is code
<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>
Upvotes: 1
Views: 109
Reputation: 309
Use following code. It will work for you
<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>
Upvotes: 1