Slt à tous, je fais une application sous mysql/php et j'aimerai transmettre une variable par un lien et là j'y arrive vraiment pas.
voici le code:
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
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
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<link rel="stylesheet" media="screen" type="text/css" title="fichier" href="fichier.css" />
    <head>
        <title>Faisceaux</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
<?php
if (isset($_POST['nom_faisceau(srce)'])AND isset ($_POST['nom_faisceau(dest)']) AND isset($_POST['libelle']) AND isset($_POST['point_code']) AND isset($_POST['type_faisceau']) AND isset($_POST['type_reseau']) AND isset($_POST['nbre_circuit']) AND isset($_POST['genre']) AND isset($_POST['centre'])) // Si les variables existent
{
// si on a qlqe choz à choisir
if(($_POST['centre']!= NULL)&&( $_POST['nom_faiceau(srce)']!= NULL) )
  {
  mysql_connect("localhost", "root","");//se connecter à la base de donnée
    mysql_select_db("correspondance"); //selection de la BD
	// on utilise les fonctions PHP mysql_real_escape_string et htmlspecialchars pour la sécurité
	$centre= mysql_real_escape_string(htmlspecialchars($_POST['centre']));
	$nom_faisceau_source= mysql_real_escape_string(htmlspecialchars($_POST['nom_faisceau_source']));
    //ensuite on enregistre le message
	mysql_close();//deconnexion de mysql
  }
}
//Que l'on ait choisi un centre ou pas
//On affiche le formulaire
?>
    <!-- L'en-tête -->
 
       <div id="en_tete">
       <p><h2>FAISCEAUX</h2></p>
       </div>
<hr/>
       <!-- Le corps -->
<div id="corps">
<form method="post" action="faisceaux.php">
Veuillez choisir un centre pour voir ces faisceaux :<br/>
 
 
       Centre:    <select name="centre" id="centre">
	          <option value=""></option>
              <option value="1"  >SSP1 ou MSC1</option>
              <option value="2" >SSP2 ou MSC2</option>
			  <option value="3" >MSC3</option>
              </select>
			  <input type="submit" value="Voir tous les faisceaux" /><br/>
			  Recherche du faisceau par nom<br/>
			  Nom Faisceau:   <input type="text" name="nom_faisceau" value="Nom_Faisceau" />
			  <input type="submit"  />
</form>
</div>
<?php
if(isset($_POST['centre']) AND isset($_POST['nom_faisceau']))
{
	$centre=$_POST['centre'];
	$nom_faisceau=$_POST['nom_faisceau'];
 
}
// Maintenant on affiche tous les faisceaux du centre selectionné
// On se connecte d'abord à MySQL :
mysql_connect("localhost", "root", "");
mysql_select_db("correspondance");
// On utilise la requête suivante pour récupérer les infos sur le faisceau correspondant
$reponse = mysql_query("SELECT ID, Nom_Faisceau_S, Nom_Faisceau_D, Libelle, Point_code_S, Point_Code_D, Type_Faisceau, Type_reseau, Genre  FROM faisceau WHERE (nom_faisceau_S = '$nom_faisceau') OR  (centre_id = '$centre')" ) or die (mysql_error());
// On se déconnecte de MySQL
mysql_close();
?>
<div id="voir">
<table border="1">
<tr>
	<td><b> Nom_Faisceau_Source <b></td>
	<td><b> Nom_Faisceau_Dest <b></td>
	<td><b> Libelle <b></td>
	<td><b> PC_Source <b></td>
	<td><b> PC_Dest <b></td>
	<td><b> Type_Faisceau <b></td>
	<td><b> Type_Reseau <b></td>
	<td><b> Genre <b></td><b>
</tr>
<?php while($data2 = mysql_fetch_assoc($reponse))
   {
   $id='id';
?>
		<tr>
		<td><a href="test_Mic.php"?&id ='$id'><?php echo $data2['Nom_Faisceau_S'];?></a></td>
		<td><?php echo $data2['Nom_Faisceau_D'];?></td>
		<td><?php echo $data2['Libelle'];?></td>
		<td><?php echo $data2['Point_code_S'];?></td>
		<td><?php echo $data2['Point_Code_D'];?></td>
		<td><?php echo $data2['Type_Faisceau'];?></td>
		<td><?php echo $data2['Type_reseau'];?></td>
		<td><?php echo $data2['Genre'];?></td>
		</tr>
	<?php } //fin du while 
?>
</table>
</div>
    </body>
</html>
A partir de la ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
<tr>
		<td><a href="test_Mic.php"?&id ='$id'><?php echo $data2['Nom_Faisceau_S'];?></a></td>
je fais le lien vers la page test_mic et sur cette dernière je dois récupérer la variable transmise pour faire une autre requête avec.
Code de la page test_mic:
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<link rel="stylesheet" media="screen" type="text/css" title="fichier" href="fichier.css" />
    <head>
        <title>Faisceaux</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
	<br/>
<h3> LES MICS DU FAISCEAU SELECTIONNE</h3>
<br/><br/>
<?php
if (isset($_GET['id'])) // Si les variables existent
 {
 	$faisceau_id = $_GET['id'];
 }
 // Maintenant on affiche tous les mic du faisceau selectionné
// On se connecte d'abord à MySQL :
mysql_connect("localhost", "root", "");
mysql_select_db("correspondance");
// On utilise la requête suivante pour afficher les mic du faisceau
$reponse = mysql_query("SELECT Nom_mic, AMET, Aflr, Cic, Adr_A, Trib_A, Port_A, Adr_B, Trib_B, Port_B FROM mic WHERE (faisceau_id_faisceau = '$faisceau_id') ") or die (mysql_error());
$data2 = mysql_fetch_assoc($reponse);
// On se déconnecte de MySQL
mysql_close();
?>
<div id="voir">
<table border="1">
<tr>
    <td><b> Nom_mic <b></td>
	<td><b> AMET <b></td>
	<td><b> Aflr <b></td>
	<td><b> Cic <b></td>
	<td><b> Adr_A <b></td>
	<td><b> Trib_A <b></td>
	<td><b> Port_A <b></td>
	<td><b> Adr_B <b></td>
	<td><b> Trib_B <b></td>
	<td><b> Port_B <b></td>
</tr>
<?php while($data2 = mysql_fetch_assoc($reponse))
   {
?>
		<tr>
		<td><?php echo $data2['Nom_mic'];?></td>
		<td><?php echo $data2['AMET'];?></td>
		<td><?php echo $data2['Aflr'];?></td>
		<td><?php echo $data2['Cic'];?></td>
		<td><?php echo $data2['Adr_A'];?></td>
		<td><?php echo $data2['Trib_A'];?></td>
		<td><?php echo $data2['Port_A'];?></td>
		<td><?php echo $data2['Adr_B'];?></td>
		<td><?php echo $data2['Trib_B'];?></td>
		<td><?php echo $data2['Port_B'];?></td>
		</tr>
	<?php } //fin du while 
?>
</table>
</div>
    </body>
</html>