PDA

View Full Version : script problem


0810
11-01-2002, 05:19 AM
I am trying to run this script. it should be 10 numbers each page. When a user clicks next, it goes 11-20number(2page). Then if one clicks Privious Page, it goes back to 1-10numbers(1page).

However it doesn't come a link "Privious Page". Moreover, it doesn't go to Next page 11-20numbers(2page).

Please fix my code

My php is 4.22

Here is code
[/php]
<html>
<head>
<title></title>
</head>
<body>
<?php

if (isset($_POST["page"]))
{
$page = $_POST["page"];
} else {
$page = 1;
}

if($page>10)
{
$page = 10;

}
print($page."Page<br><br>\n");
for($i=1; $i<=10; $i++)
{
print("No.". (($page - 1) * 10 + $i)."<br>\n");

}
print("<br>\n");

if($page != 1)
{
print("<a href=\"ito1.php?page=" . ($page -1) . "\">Privious Page</a>");


}
if($page != 10){

print("<a href=\"Fixed6.php?page=" . ($page + 1) . "\">Next Page</a>");

}

echo ("<br>\n");

?>

</body>
</html>
[php]

mordred
11-01-2002, 02:04 PM
There is no HTML form in this page that could send POST variables to the next page. Furthermore, you are explicitly passing the variables as GET variables because you add them to the query string of the URLs in the hyperlinks.

Ergo: Use $_GET instead of $_POST.