Bonjour,
J'aimerais votre aide pour créer une variable variable.
En effet, j'aimerais faire changer une image selon cette variable. Voici ce que j'ai essayé mais qui ne fonctionne pas.
La variable "$checked_image" doit donc devenir '$checked_image_1" ou "_1" est variable selon l'identifiant reçu par "$_GET['id_sous_type_article']".
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 if(!empty($_GET['id_sous_type_article'])) { $debut ='_checked'; $suite = intval($_GET['id_sous_type_article']); $suite ='_'.$suite; //ex : _1 $checked_image = ${$debut.'_'.$suite}; } echo'<p class="flottante2"><a href="/php/articles/index.php?id_type_article='.$id_type_article.'&id_sous_type_article=1" title="Vélo"><img src="/php/images/mountain_bike'.$checked_image_1.'.png" border="0" alt="Icône vélo"></a></p>'; echo'<p class="flottante2"><a href="/php/articles/index.php?id_type_article='.$id_type_article.'&id_sous_type_article=2" title="Randonnée"><img src="/php/images/hikking'.$checked_image_2.'.png" border="0" alt="Icône randonneurs"></a></p>'; echo'<p class="flottante2"><a href="/php/articles/index.php?id_type_article='.$id_type_article.'&id_sous_type_article=3" title="Sécurité et cartographie"><img src="/php/images/safety'.$checked_image_3.'.png" border="0" alt="Icône croix secours"></a></p>'; echo'<p class="flottante2"><a href="/php/articles/index.php?id_type_article='.$id_type_article.'&id_sous_type_article=4" title="Vêtements"><img src="/php/images/cloth'.$checked_image_3.'.png" border="0" alt="Icône ceintre vêtement"></a></p>'; echo'<p class="flottante2"><a href="/php/articles/index.php?id_type_article='.$id_type_article.'&id_sous_type_article=5" title="Bivouac"><img src="/php/images/sleep'.$checked_image_4.'.png" border="0" alt=""></a></p>'; echo'<p class="flottante2"><a href="/php/articles/index.php?id_type_article='.$id_type_article.'&id_sous_type_article=6" title="Autre"><img src="/php/images/other'.$checked_image_5.'.png" border="0" alt="Icône point d\'interrogation"></a></p>';
par avance, merci pour le coup de main![]()
Partager