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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
| <?php
session_start();
include('includes/haut.php');
include('includes/menu.php');
include('includes/menu_d.php');
?>
<div id="page_principale">
<br>
<?
if (empty($_SESSION['recherche'])) {
if ((isset($_POST['type']) && strlen($_POST['type']))) {
$_SESSION['recherche']['type'] = $_POST['type'];
}
if ((isset($_POST['bien']) && strlen($_POST['bien']))) {
$_SESSION['recherche']['bien'] = $_POST['bien'];
}
if ((isset($_POST['ville']) && strlen($_POST['ville']))) {
$_SESSION['recherche']['ville'] = $_POST['ville'];
}
if ((isset($_POST['tri']) && strlen($_POST['tri']))) {
$_SESSION['recherche']['tri'] = $_POST['tri'];
}
if (isset($_POST['budget_min']) && isset($_POST['budget_max'])
&& ctype_digit($_POST['budget_min']) && ctype_digit($_POST['budget_max']))
{
$_SESSION['recherche']['budget_min'] = $_POST['budget_min'];
$_SESSION['recherche']['budget_max'] = $_POST['budget_max'];
}
}
// montage du critère
$where = array();
if ( ! empty($_SESSION['recherche'])) {
foreach($_SESSION['recherche'] as $field => $value) {
if (($field !== 'budget_min') && ($field !== 'budget_max')) {
$where[] = "$field = '".mysql_real_escape_string($value)."'";
}
}
}
if (isset($_SESSION['recherche']['budget_min'])) {
$where[] = 'prix BETWEEN '.$_SESSION['recherche']['budget_min'].' AND '.$_SESSION['recherche']['budget_max'];
}
$target_page = "particuliers_rech.php";
$sql_where = (empty($where)) ? null : 'WHERE '.implode(' AND ', $where);
$result=mysql_query ('SELECT * FROM arc_achat '.$sql_where) or die(mysql_errno().' :: '.mysql_error());
$anno = mysql_num_rows($result);
if ($anno==' ') {
echo'<table width="100%" border="0" bgcolor="#FFFFFF"><tr>
<td align="center"><i>Aucune annonce.</i></td></tr></table>';
exit();
}
// on compte le nombre total d'enregistrements renvoyés par la requête filtrée
$sql = 'SELECT COUNT(*) AS nbOfRec FROM arc_achat '.$sql_where;
$qry = mysql_query($sql) or die(mysql_errno().' :: '.mysql_error());
$nb_records = mysql_result($qry, 0, 0);
echo' <b><font size="5">Résultat de la recherche :<br><font color="#FF0000"> '.$nb_records.' biens correspondant à vos critères de recherche ont été trouvés.</font></b><hr>';
// on vérifie si la page demandée est dans les limites fixées par la pagination
$nb_items_per_page = 10;
$nb_pages = ceil($nb_records / $nb_items_per_page);
$asked_page = (isset($_GET['page']) && ctype_digit($_GET['page']) && ($_GET['page']))
? (int) $_GET['page']
: 1;
if ($nb_records === 0) {
$asked_page = 1;
}
else
if ($asked_page > $nb_pages) {
// si la page demandée est supérieure au nombre total de pages alors
// page demandée = dernière page
$asked_page = $nb_pages;
}
// on détermine la clause LIMIT du sql à partir des données de pagination
$offset = ($asked_page - 1) * $nb_items_per_page;
$length = $nb_items_per_page;
$sql_limit = "LIMIT $offset, $length";
// on extrait les données à afficher
$sql = "SELECT * FROM arc_achat $sql_where $sql_limit";
$data = mysql_query($sql) or die(mysql_error());
// PAGINATION //
// je suppose que ton index affiche 10 pages
$index_range = 10;
// détermination des bornes à afficher
if ($nb_pages <= $index_range) {
$index_start = 1;
$index_end = $nb_pages;
}
else
if ($asked_page === 1) {
$index_start = 1;
$index_end = $index_range;
}
else {
$index_start = $asked_page;
$index_end = (($index_start + $index_range) > $nb_pages) ? $nb_pages : ($index_start + $index_range);
}
// affichage des liens spéciaux : Premier Précedent Suivant Dernier
$show_first = ($index_start > 1);
$show_prev = ($asked_page > 1);
$show_next = ($asked_page < $nb_pages);
$show_last = ($index_end < $nb_pages);
// génération des la pagination
$paginate = array();
$paginate[] = '<div class="paginate">';
// lien Premier
if ($show_first) {
$paginate[] = '<font size="5"><b><a href="'.$target_page.'?page=1" style="color:ff40a0;text-decoration:none;">First</font></b></a>';
}
// lien Précédent
if ($show_prev) {
$paginate[] = '<font size="5"><b><a href="'.$target_page.'?page='.($asked_page - 1).'" style="color:ff40a0;text-decoration:none;">Page précédente <<</font></b></a> ';
}
// affichage des numéros des pages
for ($i = $index_start; $i <= $index_end; ++$i) {
$paginate[] = ($i === $asked_page)
? '<span class="current"><font color="#ff40a0" size="5"><b>'.$i.'</b></font></span> '
: '<font size="5"><b><a href="'.$target_page.'?page='.$i.'" style="color:000000;text-decoration:none;">'.$i.'</font></b></a> ';
}
// lien Suivant
if ($show_next) {
$paginate[] = ' <font size="5" color="#ff40a0"><b><a href="'.$target_page.'?page='.($asked_page + 1).'" style="color:ff40a0;text-decoration:none;">Page suivante >></font></b></a>';
}
// lien Dernier
if ($show_last) {
$paginate[] = '<font size="5" color="#ff40a0"><b><a href="'.$target_page.'?page='.$index_end.'" style="color:ff40a0;text-decoration:none;">Last</a></font></b>';
}
$paginate[] = '</div>';
?>
<?
echo implode(null, $paginate);
?><br>
<?
while($plus = mysql_fetch_assoc($data))
{
$ligne = $data["idA"];
//Affichage l'aannonce
?>
<center><div style="background-image:url('images/fond_bien.png');background-repeat:no-repeat; width:650px; height:308px;">
<table width=650>
<td width=320>
<?
echo'<br><center><img src="http://www.agence-les-arcades.fr/Admin/Images/'.$plus['photo'].'" alt="Aucune photo" width="300" height="260" /></center>';
?>
</td>
<td>
<?
echo '<center><b><font size="6">'.stripslashes(htmlspecialchars($plus['bien'])).'</font></b><br><font size="5">'.stripslashes(htmlspecialchars($plus['ville'])).'</font><br><font size="6" color="#ff40a0"><b>'.stripslashes(htmlspecialchars($plus['prix'])).'
</font></b><br><br><font size="6"><b><a href="biens.php?id='.$plus['id'].'&action=consulter" style="color:000000;text-decoration:none;">> Détails</b></a></font></center>';
?>
</td>
</tr>
</table><br>
</div></center><br><br>
<?
}
?> |
Partager