par
turkish15 » 10 avr. 2014, 15:50
Bonjour à tous, j'ai besoin d'aide au sujet de l'affichage des données d'une entité que j'aurais sélectionnée dans une liste déroulante.
Dans ma 1er liste j'ai des groupes d'exploitations et dans ma 2eme liste j'ai les agences qui appartiennent à chaque groupe, ce que j’essaye de faire c'est d'afficher les infos de l'agence sélectionnée.
C-à-d que je sélectionne un groupe dans ma 1ére liste, je sélectionne une agence qui appartiens à ce groupe dans ma deuxième liste,et quand je sélectionne ladite agence, j'aurais toutes les infos la concernant
voilà mon code, je n'arrive pas à trouver où ça coince :
<?php
session_start();
$serveur = "localhost";
$admin = "root";
$mdp = "";
$base = "regions";
$connexion = mysql_connect($serveur, $admin, $mdp);
mysql_select_db($base, $connexion);
if(isset($_POST['gexp'])){
$_SESSION['gexp'] = $_POST['gexp'];
echo 'vous avez choisi le Groupe d\'Exploitation '.$_SESSION['gexp'].'<br />'. '<br />';
}
if(isset($_POST['agency'])){
$_SESSION['agency'] = $_POST['agency'];
echo 'vous avez choisi l\'Agence '.$_SESSION['agency'].'<br />';
}
?>
Choisissez un groupe d'exploitation
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="chg_gexp">
<select name="gexp" id="gexp" onchange="document.forms['chg_gexp'].submit();">
<option>- - - Choisissez un groupe d'exploitation - - -</option>
<?php
$sql1 = "SELECT `id`, `nomgroupe`
FROM `groupex`
ORDER BY `id`";
$rech_groupe = mysql_query($sql1);
if($rech_groupe != false){
while($ligne = mysql_fetch_assoc($rech_groupe)){ ?>
<option value="<?php echo $ligne['id']; ?>"
<?php if(isset($_SESSION['gexp'])
AND $_SESSION['gexp'] == $ligne['id'])
echo 'selected="selected"'; ?>>
<?php echo $ligne['nomgroupe']; ?>
</option>
<?php
}
}
mysql_free_result($rech_groupe);
?>
</select>
</form>
choisir une Agence
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="chg_agency">
<select name="agency" id="agency" onchange="document.forms['chg_agency'].submit();">
<option>- - - Choisissez une agence - - -</option>
<?php
if(isset($_SESSION['gexp'])){
$sql2 = "SELECT `code`, `nom`
FROM `agences`
WHERE `id` = ". $_SESSION['gexp'] ."
ORDER BY `code`;";
$rech_agence = mysql_query($sql2);
if($rech_agence != false){
while($ligne = mysql_fetch_assoc($rech_agence)){ ?>
<option value="<?php echo $ligne['code']; ?>"
<?php if(isset($_SESSION['gexp'])
AND$_SESSION['agency'] == $ligne['code'])
echo 'selected="selected"'; ?>>
<?php echo $ligne['nom']; ?>
</option>
<?php
}
}
mysql_free_result($rech_agence);
}
?>
</select>
</form>
<?php
if (isset($_SESSION['gpex']) && isset($_SESSION['agency'])){
$agency_info = $mysqli->query("SELECT * FROM 'agences' WHERE 'id'='".$_SESSION['agency']."'")->fetch_assoc();
?>
<hr/>
<table width="500" border="1" summary="Ceci représente l'information sur l'agence sélectionnée.">
<caption>
Description de l'agence sélectionnée
</caption>
<tr>
<th width="276" scope="row">Code de l'agence :</th>
<td width="214"><?php echo $agency_info['code']; ?></td>
</tr>
<tr>
<th scope="row">Nom de l'agence :</th>
<td><?php echo $agency_info['nom']; ?></td>
</tr>
<tr>
<th scope="row">Adresse :</th>
<td><?php echo $agency_info['adresse']; ?></td>
</tr>
<tr>
<th scope="row">E_mail :</th>
<td><?php echo $agency_info['email']; ?></td>
</tr>
<tr>
<th scope="row">Numero de téléphone :</th>
<td><?php echo $agency_info['num']; ?></td>
</tr>
<tr>
<th scope="row">Fax. :</th>
<td><?php echo $agency_info['fax']; ?></td>
</tr>
</table>
<?php }?>
Bonjour à tous, j'ai besoin d'aide au sujet de l'affichage des données d'une entité que j'aurais sélectionnée dans une liste déroulante.
Dans ma 1er liste j'ai des groupes d'exploitations et dans ma 2eme liste j'ai les agences qui appartiennent à chaque groupe, ce que j’essaye de faire c'est d'afficher les infos de l'agence sélectionnée.
C-à-d que je sélectionne un groupe dans ma 1ére liste, je sélectionne une agence qui appartiens à ce groupe dans ma deuxième liste,et quand je sélectionne ladite agence, j'aurais toutes les infos la concernant
voilà mon code, je n'arrive pas à trouver où ça coince :
[php]
<?php
session_start();
$serveur = "localhost";
$admin = "root";
$mdp = "";
$base = "regions";
$connexion = mysql_connect($serveur, $admin, $mdp);
mysql_select_db($base, $connexion);
if(isset($_POST['gexp'])){
$_SESSION['gexp'] = $_POST['gexp'];
echo 'vous avez choisi le Groupe d\'Exploitation '.$_SESSION['gexp'].'<br />'. '<br />';
}
if(isset($_POST['agency'])){
$_SESSION['agency'] = $_POST['agency'];
echo 'vous avez choisi l\'Agence '.$_SESSION['agency'].'<br />';
}
?>
Choisissez un groupe d'exploitation
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="chg_gexp">
<select name="gexp" id="gexp" onchange="document.forms['chg_gexp'].submit();">
<option>- - - Choisissez un groupe d'exploitation - - -</option>
<?php
$sql1 = "SELECT `id`, `nomgroupe`
FROM `groupex`
ORDER BY `id`";
$rech_groupe = mysql_query($sql1);
if($rech_groupe != false){
while($ligne = mysql_fetch_assoc($rech_groupe)){ ?>
<option value="<?php echo $ligne['id']; ?>"
<?php if(isset($_SESSION['gexp'])
AND $_SESSION['gexp'] == $ligne['id'])
echo 'selected="selected"'; ?>>
<?php echo $ligne['nomgroupe']; ?>
</option>
<?php
}
}
mysql_free_result($rech_groupe);
?>
</select>
</form>
choisir une Agence
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="chg_agency">
<select name="agency" id="agency" onchange="document.forms['chg_agency'].submit();">
<option>- - - Choisissez une agence - - -</option>
<?php
if(isset($_SESSION['gexp'])){
$sql2 = "SELECT `code`, `nom`
FROM `agences`
WHERE `id` = ". $_SESSION['gexp'] ."
ORDER BY `code`;";
$rech_agence = mysql_query($sql2);
if($rech_agence != false){
while($ligne = mysql_fetch_assoc($rech_agence)){ ?>
<option value="<?php echo $ligne['code']; ?>"
<?php if(isset($_SESSION['gexp'])
AND$_SESSION['agency'] == $ligne['code'])
echo 'selected="selected"'; ?>>
<?php echo $ligne['nom']; ?>
</option>
<?php
}
}
mysql_free_result($rech_agence);
}
?>
</select>
</form>
<?php
if (isset($_SESSION['gpex']) && isset($_SESSION['agency'])){
$agency_info = $mysqli->query("SELECT * FROM 'agences' WHERE 'id'='".$_SESSION['agency']."'")->fetch_assoc();
?>
<hr/>
<table width="500" border="1" summary="Ceci représente l'information sur l'agence sélectionnée.">
<caption>
Description de l'agence sélectionnée
</caption>
<tr>
<th width="276" scope="row">Code de l'agence :</th>
<td width="214"><?php echo $agency_info['code']; ?></td>
</tr>
<tr>
<th scope="row">Nom de l'agence :</th>
<td><?php echo $agency_info['nom']; ?></td>
</tr>
<tr>
<th scope="row">Adresse :</th>
<td><?php echo $agency_info['adresse']; ?></td>
</tr>
<tr>
<th scope="row">E_mail :</th>
<td><?php echo $agency_info['email']; ?></td>
</tr>
<tr>
<th scope="row">Numero de téléphone :</th>
<td><?php echo $agency_info['num']; ?></td>
</tr>
<tr>
<th scope="row">Fax. :</th>
<td><?php echo $agency_info['fax']; ?></td>
</tr>
</table>
<?php }?>
[/php]