par
sbomb » 06 déc. 2011, 11:47
Autant pour moi, voici mon traitement (qui utilise une pagination):
<?php
require_once("connect.php");
$lien=connect_bdd();
if(($_SESSION['selectType'] && $_SESSION['prix1'] && $_SESSION['prix2'] && $_SESSION['capacite'] && $_SESSION['localisation'])=="--Choix--"){
$select='SELECT count(id_residence) FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire ';
}
if(($_SESSION['selectType'])!="--Choix--"){
$select='SELECT count(id_residence) FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire AND r.prix >= '.$_SESSION['prix1'].' AND r.prix <= '.$_SESSION['prix2'].' AND r.capacite >= '.$_SESSION['capacite'].' AND r.localisation <= '.$_SESSION['localisation'].' ';
}
$resultat = mysql_query($select);
$nb_total = mysql_fetch_array($resultat);
if (($nb_total = $nb_total[0]) == 0) {
echo "Aucun résultat ne correspond â votre recherche!";
}
else {
echo "<table>";
echo "<caption>Liste des hébergements</caption>";
echo "<thead>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://bainslesbains-tourisme.fr/stage/css/styleResult.css\" />";
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
echo '</thead><tbody>';
if (!isset($_GET['debut'])) $_GET['debut'] = 0;
$nb_affichage_par_page = 6;
if(($_SESSION['selectType'] && $_SESSION['prix1'] && $_SESSION['prix2'] && $_SESSION['capacite'] && $_SESSION['localisation'])=="--Choix--"){
$requete='SELECT r.nom_residence, r.ville_residence, r.capacite, r.prix, r.nblogement, r.url_photo1, p.nom_proprietaire, r.code_classement, r.gite, r.id_type, r.id_proprietaire FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire ORDER BY code_classement DESC, r.prix DESC, r.nom_residence ASC limit '.$_GET['debut'].','.$nb_affichage_par_page.' ';
}
if(($_SESSION['selectType'])=="--Choix--"){
$requete='SELECT r.nom_residence, r.ville_residence, r.capacite, r.prix, r.nblogement, r.url_photo1, p.nom_proprietaire, r.code_classement, r.gite, r.id_type, r.id_proprietaire FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire AND r.prix >= '.$_SESSION['prix1'].' AND r.prix <= '.$_SESSION['prix2'].' AND r.capacite >= '.$_SESSION['capacite'].' AND r.localisation <= '.$_SESSION['localisation'].' ORDER BY code_classement DESC, r.prix DESC, r.nom_residence ASC limit '.$_GET['debut'].','.$nb_affichage_par_page.' ';
}
mysql_query("SET NAMES 'utf8'");
$req=mysql_query($requete);
while(($liste_hebergement=mysql_fetch_array($req))!=NULL){
.....
}
edit: Les 2 requetes, ne fonctionne pas, je pense que je dois mal utiliser mes $_SESSION et leur égalité avec la valeur "--Choix--"
edit2: Le $_SESSIOn sont bien recupere dans un session start en debut de code, mais que je n'ai pas "citer"
Autant pour moi, voici mon traitement (qui utilise une pagination):
[php]
<?php
require_once("connect.php");
$lien=connect_bdd();
if(($_SESSION['selectType'] && $_SESSION['prix1'] && $_SESSION['prix2'] && $_SESSION['capacite'] && $_SESSION['localisation'])=="--Choix--"){
$select='SELECT count(id_residence) FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire ';
}
if(($_SESSION['selectType'])!="--Choix--"){
$select='SELECT count(id_residence) FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire AND r.prix >= '.$_SESSION['prix1'].' AND r.prix <= '.$_SESSION['prix2'].' AND r.capacite >= '.$_SESSION['capacite'].' AND r.localisation <= '.$_SESSION['localisation'].' ';
}
$resultat = mysql_query($select);
$nb_total = mysql_fetch_array($resultat);
if (($nb_total = $nb_total[0]) == 0) {
echo "Aucun résultat ne correspond â votre recherche!";
}
else {
echo "<table>";
echo "<caption>Liste des hébergements</caption>";
echo "<thead>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://bainslesbains-tourisme.fr/stage/css/styleResult.css\" />";
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
echo '</thead><tbody>';
if (!isset($_GET['debut'])) $_GET['debut'] = 0;
$nb_affichage_par_page = 6;
if(($_SESSION['selectType'] && $_SESSION['prix1'] && $_SESSION['prix2'] && $_SESSION['capacite'] && $_SESSION['localisation'])=="--Choix--"){
$requete='SELECT r.nom_residence, r.ville_residence, r.capacite, r.prix, r.nblogement, r.url_photo1, p.nom_proprietaire, r.code_classement, r.gite, r.id_type, r.id_proprietaire FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire ORDER BY code_classement DESC, r.prix DESC, r.nom_residence ASC limit '.$_GET['debut'].','.$nb_affichage_par_page.' ';
}
if(($_SESSION['selectType'])=="--Choix--"){
$requete='SELECT r.nom_residence, r.ville_residence, r.capacite, r.prix, r.nblogement, r.url_photo1, p.nom_proprietaire, r.code_classement, r.gite, r.id_type, r.id_proprietaire FROM RESIDENCE r, TYPE t, PROPRIETAIRE p WHERE t.id_type = r.id_type AND p.id_proprietaire = r.id_proprietaire AND r.prix >= '.$_SESSION['prix1'].' AND r.prix <= '.$_SESSION['prix2'].' AND r.capacite >= '.$_SESSION['capacite'].' AND r.localisation <= '.$_SESSION['localisation'].' ORDER BY code_classement DESC, r.prix DESC, r.nom_residence ASC limit '.$_GET['debut'].','.$nb_affichage_par_page.' ';
}
mysql_query("SET NAMES 'utf8'");
$req=mysql_query($requete);
while(($liste_hebergement=mysql_fetch_array($req))!=NULL){
.....
}
[/php]
edit: Les 2 requetes, ne fonctionne pas, je pense que je dois mal utiliser mes $_SESSION et leur égalité avec la valeur "--Choix--"
edit2: Le $_SESSIOn sont bien recupere dans un session start en debut de code, mais que je n'ai pas "citer"