Bonjour,
Je suis entrain de créer un site qui permettrai de passer des annonces gratuites. En fait le problème que je rencontre en ce moment est que je n'arrive pas à afficher les annonces de chaque région.
Quand je clique sur une région j'ai le résultat de cette région et quand je clique sur une autre région j'ai toujours le résultat de la première région qui correspond l'ID=1 de la table Région.
J'ai revu mon code, Seulement quand j'ai revu ma table "RÉGION" j'ai découvert que quand je change la valeur de la première région par une autre j'ai les résultats exacts de cette région là.
Par exemple:
Si La première ligne de la table Région est Dakar ----le résultat affiche les annonces de Dakar
Si la 2eme ligne de la table Région est Thies j'ai toujours le résultat de Dakar.
Mais quand je change Dakar par Thies = J'ai les annonces de Thies
Mais toujours les autres régions n'affichent que les annonces Thies aussi
En fait MYSQL ne lit que la valeur du premier enregistrement c'est à dire IDREGION=1.
Ma question est de savoir comment arriver à afficher les annonces de chaque région.
Voici ma requete MYSQL
Le code qui me permettrait d'afficher les annonces.
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 $colname_Recordset4 = "-1"; if (isset($_SESSION['idregion'])) { $colname_Recordset4 = (get_magic_quotes_gpc()) ? $_SESSION['idregion'] : addslashes($_SESSION['idregion']); } mysql_select_db($database_connexion, $connexion); $query_Recordset4 = sprintf("SELECT * FROM an_regions WHERE idregion", $colname_Recordset4); $Recordset4 = mysql_query($query_Recordset4, $connexion) or die(mysql_error()); $row_Recordset4 = mysql_fetch_assoc($Recordset4); $totalRows_Recordset4 = mysql_num_rows($Recordset4); $regionaffiche = $row_Recordset4['region']; $maxRows_afficheannonce = 10; $pageNum_afficheannonce = 0; if (isset($_GET['pageNum_afficheannonce'])) { $pageNum_afficheannonce = $_GET['pageNum_afficheannonce']; } $startRow_afficheannonce = $pageNum_afficheannonce * $maxRows_afficheannonce; mysql_select_db($database_connexion, $connexion); $query_afficheannonce = "SELECT * FROM `an_annonce`WHERE regions = '$regionaffiche' AND vala = 'y' And pause= 'n' ORDER BY `date` DESC"; $query_limit_afficheannonce = sprintf("%s LIMIT %d, %d", $query_afficheannonce, $startRow_afficheannonce, $maxRows_afficheannonce); $afficheannonce = mysql_query($query_limit_afficheannonce, $connexion) or die(mysql_error()); $row_afficheannonce = mysql_fetch_assoc($afficheannonce);
La structure de la table REGION
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 <?php do { ?> <?php if ($totalRows_afficheannonce > 0) { // Show if recordset not empty ?> <table width="300" height="50" border="0" cellpadding="2" cellspacing="0" class=" <?php switch ($row_afficheannonce['vala'] And $row_afficheannonce['pause']){ case"y": $cadre="cadredroite"; break; case"n": $cadre="cadredroitepasvalide"; break;} echo "$cadre"; ?>"> <tr> <td width="300" height="50"><div align="center"><?php echo strtoupper($row_afficheannonce['nomcat']); ?> / <?php if($row_afficheannonce['nsouscat']=='rien'){$row_afficheannonce['nsouscat']="";}echo ucfirst($row_afficheannonce['nsouscat']); ?> </div></td> <td width="50"><div align="right">ref:<?php echo $row_afficheannonce['idannonce']; ?></div></td> </tr> <tr> <td height="30" colspan="2"><strong> <a href="../Annonce/annonces/voir_annonce.php?idannonce=<?php echo $row_afficheannonce['idannonce']; ?>" target="_blank"><?php echo ucfirst($row_afficheannonce['sujet']); ?></a> <?php if ($row_afficheannonce['photo1']!="" or $row_afficheannonce['photo2']!="") { // Show if recordset not empty ?> <?php } // Show if recordset not empty ?> <?php echo $vu ?> <?php echo $row_afficheannonce['vu']; ?> <?php echo $fois ?> </td> </tr> <tr> <td height="20" colspan="2"><?php echo $row_afficheannonce['message']; ?> <br /> <br /><br> <strong><?php echo $row_afficheannonce['regions']; ?></strong> <em><strong><?php echo $row_afficheannonce['date']; ?></strong></em> <em><strong><?php echo ucfirst($row_afficheannonce['pseudo']); ?></strong></em></td> </td> </tr> </table><br /><hr /> <?php } // Show if recordset not empty ?> <br> <?php } while ($row_afficheannonce = mysql_fetch_assoc($afficheannonce)); ?></td> <br /> <table border="0" width="600" align="center"> <tr> <td width="23%" align="center"><?php if ($pageNum_afficheannonce > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_afficheannonce=%d%s", $currentPage, 0, $queryString_afficheannonce); ?>">Premier</a> <?php } // Show if not first page ?> </td> <td width="31%" align="center"><?php if ($pageNum_afficheannonce > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_afficheannonce=%d%s", $currentPage, max(0, $pageNum_afficheannonce - 1), $queryString_afficheannonce); ?>">Précédent</a> <?php } // Show if not first page ?> </td> <td width="23%" align="center"><?php if ($pageNum_afficheannonce < $totalPages_afficheannonce) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_afficheannonce=%d%s", $currentPage, min($totalPages_afficheannonce, $pageNum_afficheannonce + 1), $queryString_afficheannonce); ?>">Suivant</a> <?php } // Show if not last page ?> </td> <td width="23%" align="center"><?php if ($pageNum_afficheannonce < $totalPages_afficheannonce) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_afficheannonce=%d%s", $currentPage, $totalPages_afficheannonce, $queryString_afficheannonce); ?>">Dernier</a> <?php } // Show if not last page ?> </td> </tr>
J'espere trouver une réponse.
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 -- -- Base de données: `galsenechange` -- -- -------------------------------------------------------- -- -- Structure de la table `an_regions` -- CREATE TABLE IF NOT EXISTS `an_regions` ( `idregion` int(20) NOT NULL AUTO_INCREMENT, `region` varchar(40) COLLATE latin1_general_ci NOT NULL DEFAULT '', `compteur` varchar(12) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`idregion`), KEY `idregion` (`idregion`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=85 ; -- -- Contenu de la table `an_regions` -- INSERT INTO `an_regions` (`idregion`, `region`, `compteur`) VALUES (1, 'Dakar', '9'), (2, 'Thies', ''), (3, 'Diourbel', '2'), (4, 'Fatick', '1'), (5, 'Kaolack', ''), (6, 'Tambacounda', '1'), (7, 'Kolda', ''), (8, 'Louga', ''), (9, 'Matam', ''), (10, 'Saint-Louis', ''), (11, 'Ziguinchor', ''), (14, 'Sedhiou', ''), (12, 'Kedougou', ''), (13, 'Kaffrine', '');
Merci d'Avance
Partager