Bonjour, j'essaye de faire un mini site d'annonces immobilières, n'étant pas un expert en php, j'y vais en tâtonnant...

J'ai une table annonces, une table localites et une table types (bureaux, terrains etc...)

Le menu du site doit donner la possibilité de lister les annonces :
1. de bureaux
2. d'entreôts
3. de terrains

Je fais passer cette variable en tant que "id" et le récupère dans ma requete.

J'arrive a obtenir les annonces en rapport avec la variable "id" mais le problème est que même s'il n'y a pas d'annonces en rapport avec "id" dans une localité, cette localité s'affiche quand même.

J'ai essayé plusieurs manières différentes mais je tourne en rond et mes compétences me limitent.

Je vous laisse ci-dessous mes requetes et boucles en espérant que vous pourrez m'éclairer.

Merci d'avance

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php
$longueur = 5000;
 
 
 
	if ($_GET['page']>0)
	{
 	$min=($_GET['page']*5);
	}
	else
	{
 	$min=0;
	}
 
 
 
		$resultat = mysql_db_query("$base","SELECT * FROM localites ORDER BY localites_nom ASC LIMIT $min ,5",$connexion);
		$num = mysql_num_rows($resultat);
		$i=0;
		while($i<$num)
		 {
			$localites_id = mysql_result($resultat,$i,"localites_id");
			$localites_nom = mysql_result($resultat,$i,"localites_nom");
			$localites_texte = mysql_result($resultat,$i,"localites_texte");
			$localites_photo_1 = mysql_result($resultat,$i,"localites_photo_1");
 
				echo "<tr>";
					echo "<td class=\"nomlocalite\" height=\"18\" valign=\"top\">$localites_nom</td>";
				echo"</tr>";
				echo "<tr>";
					echo "<td width=\"100%\" height=\"1\"><img src=\"images/img-separ-annonces.gif\" border=\"0\" width=\"100%\" height=\"1\"></td>";
				echo"</tr>";
				echo "<tr>";
					echo "<td valign=\"top\" width=\"100%\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td valign=\"top\" width=\"160\"><img src=\"images/";
					if ($localites_photo_1 != ""){
					echo "$localites_photo_1";
					}
					else {
					echo "carte-en-cours.gif";
					}
					echo "\" border=\"0\" width=\"160\" height=\"132\"></td><td valign=\"top\" width=\"100%\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
 
 
				$resultat2 = mysql_db_query("$base","SELECT * FROM annonces WHERE annonces_active = 1 AND annonces_type = '$id' AND annonces_localite = '$localites_nom' ORDER BY annonces_date DESC LIMIT $min ,5",$connexion);
				   $num2 = mysql_num_rows($resultat2);
				   $j=0;
				   while($j<$num2)
					{
						$annonces_id = mysql_result($resultat2,$j,"annonces_id");
						$annonces_reference = mysql_result($resultat2,$j,"annonces_reference");
						$annonces_titre = mysql_result($resultat2,$j,"annonces_titre");
						$annonces_superficie = mysql_result($resultat2,$j,"annonces_superficie");
						$annonces_localite = mysql_result($resultat2,$j,"annonces_localite");
						$annonces_type = mysql_result($resultat2,$j,"annonces_type");
						$annonces_locvente = mysql_result($resultat2,$j,"annonces_locvente");
						$annonces_texte = mysql_result($resultat2,$j,"annonces_texte");
						$annonces_date = mysql_result($resultat2,$j,"annonces_date");
						$annonces_photo_1 = mysql_result($resultat2,$j,"annonces_photo_1");
 
 
 
				?>
après s'affichent mes annonces...