Pb de passage de variable

LoloH77
Invité n'ayant pas de compte PHPfrance

28 avr. 2011, 20:48

Débutant en PHP langue , je n'arrive pas à faire passer ma variable modifiée lors de la relance de ma page.

Une âme charitable pourrait-elle m'aider ?

voici le code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title></title>

<link rel="stylesheet" media="screen" href="ecran.css" />
</head>
<body>

<?php
/* -- inisialisation variable -- */
$pas = 5; // pas d'incrementation.
if (!isset($limite)) $limite = 0; //si premier acces a la page

/* -- Recuperation nreference de la page active -- */
$path_parts = pathinfo($_SERVER['PHP_SELF']);
$page = $path_parts['basename'];

/* -- Calcul valeurs amont et aval -- */
$limitesuivante = $limite + $pas;
$limiteprecedente = $limite - $pas;

echo '<p>'."Limite actuel = ".$limite.'</p>';
/* -- lien suivant --*/
echo '<a href="'.$page.'?limite='.$limitesuivante.'">Page Suivante</a>'
?>

</body>
</html> 


ViPHP
ViPHP | 2577 Messages

28 avr. 2011, 21:14

if (!isset($limite)) $limite = 0; //si premier acces a la page

à replacer par
if (isset($_GET['limite'])) 
{
   $limite = _GET['limite'];
}
else
{
   $limite = 0;
}