Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 28/09/2008, 00h22   #1
Membre du Club
 
Avatar de razorlok
 
Inscription : novembre 2006
Messages : 190
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 190
Points : 66
Points : 66
Par défaut Passage de variable avec href

Bonsoir,

J'ai besoin de récupérer une variable via un clic sur un href.

Le code suivant m'affiche $art comme résultat :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
<?php
	$i = 0;
		while 
		($tab = mysql_fetch_array($res)){
	$i = $i + 1;
		?>
 
<table>
<tr>
<td>
	<img src="<?php echo $tab['IMAGE']; ?>">
	</a>
</td>
<td>
 
<?php $art=$tab['NOM'];?> 
<a href="affichage.php?art=$art"><?php echo $art ?><a>
 
<br>
<?php echo $tab['GENRE'];?>	
</td>
</tr>
		<?php } ?>
Code dans la page affichage.php :

Code :
1
2
3
4
5
6
 
<?php 
$nom=$_GET['art'];
 
echo $nom; 
 ?>
l'url affiche toujours /affichage.php?art=$art
__________________
Wear some golf shoes, otherwise we'll never get out of this place alive.
razorlok est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/09/2008, 00h37   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 383
Points : 16 383
Parce que tu n'es pas dans du code PHP.
Tu as d'ailleurs plutot interet a rester dans le code plutot que d'ouvrir/fermer comme tu le fais :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php 
	$i = 0;
		while 
		($tab = mysql_fetch_array($res)){
	$i = $i + 1;
$art=$tab['NOM'];
echo ' 
<table>
<tr>
<td>
	<img src="' . $tab['IMAGE'] . '">
	</a>
</td>
<td><a href="affichage.php?art=' . $art .'">' . $art . '<a> 
<br>' . $tab['GENRE'] . '
</td>
</tr>';
}
?>
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/09/2008, 09h42   #3
Membre du Club
 
Avatar de razorlok
 
Inscription : novembre 2006
Messages : 190
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 190
Points : 66
Points : 66
En effet, ça marche très bien, merci beaucoup !
__________________
Wear some golf shoes, otherwise we'll never get out of this place alive.
razorlok est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 06h33.


 
 
 
 
Partenaires

Hébergement Web