afficher plusieurs pages apres une requete
voila je souhaite apres une selection afficher les 5 premiers résultats et s'il y en a plus afficher les 5 suivants.
La j'ai pris l'option d'un lien vers la meme page avec en bas de tableau "suivant"
Mon problème est que quand je relance la page mes données ayant servi a faire la selection n'existe plus.
Code:
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| <?php
$pays = $_POST['pays'];
$type = "Commerce";//$_POST['typecommerce'];
$region = $_POST['region'];
$cp1 = $_POST['cp1'];
$cp2= $_POST['cp2'];
$cp3 = $_POST['cp3'];
$cp4 = $_POST['cp4'];
$prixmin = $_POST['prixmin'];
$prixmax = $_POST['prixmax'];
$selection1 = $_POST['selection1'];
$selection2 = $_POST['selection2'];
if ($prixmax == "")
{
$prixmax = "10000000000000000000000";
}
$nombre = 5; // on va afficher 5 résultats par page.
if (!isset($limite)) $limite = 0; // si on arrive sur la page pour la première fois
// on met limite à 0.
$path_parts = pathinfo($_SERVER['PHP_SELF']);
$page = $path_parts['basename'];
try
{
$bdd = new PDO('mysql:host=localhost;dbname=commerces', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$reponse = $bdd->query("SELECT * FROM dossiers WHERE type='$type' and pays ='$pays' and pv <'$prixmax' and pv >'$prixmin' and (cp ='$cp1' or cp ='$cp2' or cp ='$cp3' or cp ='$cp4') ORDER BY '$selection1' ASC ")
or die(print_r($bdd->errorInfo()));
$total = $reponse -> rowCount();
//print_R ($row);
//$total = $row[0];
echo $total;
$reponse = $bdd->query("SELECT * FROM dossiers WHERE type='$type' and pays ='$pays' and pv <'$prixmax' and pv >'$prixmin' and (cp ='$cp1' or cp ='$cp2' or cp ='$cp3' or cp ='$cp4') ORDER BY '$selection1' ASC limit $limite, $nombre")
or die(print_r($bdd->errorInfo()));
?>
<table>
<caption></caption>
<thead><tr><th scope="col">Photo</th>
<th scope="col">Prix</th>
<th scope="col">Type de commerce</th>
<th scope="col">Localité</th>
<th scope="col">Description Brève</th>
</tr></thead>
<tbody>
<?php
while ($donnees = $reponse->fetch())
{
//echo '<p><strong>' . ($donnees['rue']) . '</strong> ' . ($donnees['numero']) . '</p>';
//echo '<p><strong>' . ($donnees['cp']) . '</strong> ' . ($donnees['commune']) . '</p>';
//echo '<p><strong>' . ($donnees['pays']) . '</strong> ' ;
//echo ($donnees['type']);
$photo1 = $donnees['photo1'];
$photo1 = "uploads/mini-".$photo1;
$pv = $donnees['pv'];
$type = $donnees['type'];
$cp = $donnees['cp'];
$commune = $donnees['commune'];
$description_breve = $donnees['description_breve'];
$description_breve = nl2br($description_breve);
$date = $donnees['date_debut'];
?>
<tr>
<th scope="row" id="r100"><a href="detail.php"><img src="<?php echo $photo1;?>"</a></th>
<td><?php echo$pv;?></td>
<td><a href="detail.php"><?php echo $type;?></a></td>
<td><?php echo $cp;?> <?php echo $commune;?></td>
<td><?php echo $description_breve;?></td>
</tr>
<?php
}
$reponse->closeCursor();
$limitesuivante = $limite + $nombre;
$limiteprecedente = $limite - $nombre;
?>
</tbody>
<?php
if($limitesuivante < $total) {
?>
<tfoot><tr><th scope="row">Total</th>
<td colspan="4"><a href="<?php echo $page?>?limite= <?php echo $limitesuivante?>"><font color=#FF0000>Page Suivante</font></a></td></tr></tfoot>
</table>
<?php
}
?> |
merci de me guider