1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<?php
//Config-----
$listedescategories = array('couleur'=>'Couleur','taille'=>'Taille','pays'=>'Pays d\'origine');
$valeurs = array(
'couleur'=>array('bleu','vert','rouge'),
'taille'=>array('petit','moyen','grand','pharaonique'),
'pays'=>array('Maroc','Finlande','Vatican')
);
//-----------
ini_set('display_errors',false);
if(isset($_GET['enlever'])){
unset($_GET['enlever']);
$str = vsprintf(implode('=%s&',array_keys($_GET)).'=%s',$_GET);//Voilà ce que tu cherchais
$car1 = (strlen($str)) ? '?' : '';
header("location:lien.php$car1$str");
}
?>
<!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>
<title>Hello World</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
foreach($listedescategories as $categorie=>$nomcat){ ?>
<h3><?=$nomcat?></h3>
<form method="get" action="lien.php"><div>
<?php
foreach($listedescategories as $cat=>$inutile){
if($cat==$categorie) continue;
if(isset($_GET[$cat])) echo '<input type="hidden" name="'.$cat.'" value="'.$_GET[$cat].'" />';
}
foreach($valeurs[$categorie] as $c){
if($_GET[$categorie]==$c) echo '<input type="submit" name="enlever" value="'.$c.'" />';
else echo '<input type="submit" name="'.$categorie.'" value="'.$c.'" />';
}
?>
</div></form>
<?php } ?>
</body>
</html> |
Partager