IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Problème de liste déroulante utilisant une valeur d'une autre liste [Débutant(e)] [MySQL]


Sujet :

PHP & Base de données

  1. #61
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    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
    <? require "Includes/fonctions.php"; ?>
    <?
    //ouverture du formulaire
    echo "<form action='' method='post' name='form'>";
     ?>
    <div class="titre">Selectionnez la personne</div>
     
    <?
    	//liste des personnes de l'encadrement
     
    	$reqmvt="select NOM_ENCADREMENT, PRENOM_ENCADREMENT, NUM_ENCADREMENT from ENCADREMENT order by NOM_ENCADREMENT";
    	$mvt=mysql_query($reqmvt)or die(mysql_error());
    	echo "<select name='encadrement'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$nom=strtoupper($row["NOM_ENCADREMENT"]);
    		$prenom=strtolower($row["PRENOM_ENCADREMENT"]);
    		$prenom=ucfirst($prenom);
    		echo "<option value='".$row['NUM_ENCADREMENT']."' ";
    		if (isset ($_POST['encadrement']) && $_POST['encadrement']==$row['NUM_ENCADREMENT']) echo " selected ";
    		echo "'>".$nom."&nbsp;&nbsp;".$prenom."</option>";
    	}
    	if( isset($_POST['personne']) ) echo '<input type="hidden" name="personne" value="' .$_POST['personne']. '"/>';
     
    ?>

    à l'écran j'ai le message

    Selectionnez la personne
    et ma liste déroulante avec juste
    --Selectionnez--

    et c'est tout. Rien de plus

    je te redonne tous le code de la page

    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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    <? require "Includes/fonctions.php"; ?>
    <?
    //ouverture du formulaire
    echo "<form action='' method='post' name='form'>";
     ?>
    <div class="titre">Selectionnez la personne</div>
     
    <?
    	//liste des personnes de l'encadrement
     
    	$reqmvt="select NOM_ENCADREMENT, PRENOM_ENCADREMENT, NUM_ENCADREMENT from ENCADREMENT order by NOM_ENCADREMENT";
    	$mvt=mysql_query($reqmvt)or die(mysql_error());
    	echo "<select name='encadrement'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$nom=strtoupper($row["NOM_ENCADREMENT"]);
    		$prenom=strtolower($row["PRENOM_ENCADREMENT"]);
    		$prenom=ucfirst($prenom);
    		echo "<option value='".$row['NUM_ENCADREMENT']."' ";
    		if (isset ($_POST['encadrement']) && $_POST['encadrement']==$row['NUM_ENCADREMENT']) echo " selected ";
    		echo "'>".$nom."&nbsp;&nbsp;".$prenom."</option>";
    	}
    	if( isset($_POST['personne']) ) echo '<input type="hidden" name="personne" value="' .$_POST['personne']. '"/>';
     
    ?>
     
    <div class="titre">Selectionnez sa fonction</div>
    <?
    	//liste des fonctions
     
    	$reqfonction="select LIB_FONCTION, NUM_FONCTION from FONCTION order by LIB_FONCTION";
    	$fonction=mysqlquery($reqfonction) or die (mysql_error());
    	echo "<select name='fonction'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($fonction))
    	{
    		echo '<option value="'.$val['NUM_FONCTION'].'" ';
    		if (isset ($_POST['focntion']) && $_POST['fonction']==$row['NUM_FONCTION']) echo " selected ";
    		echo '">'.$val['LIB_FONCTION'].'</option>';
    	}
     
    ?>
     
    <hr width="100%"><div class="titre">Selectionnez la discipline</div>
    <?
     
     
    	$reqmvt="select NUM_DISCIPLINE, NOM_DISCIPLINE from DISCIPLINE order by NOM_DISCIPLINE";
    	$mvt=mysql_query($reqmvt);
    	echo "<select name='discipline' onchange='form.submit()'>";
    	echo "<option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$txt=Tronquer_Texte($row["NOM_DISCIPLINE"], $longeur_max);
    		echo "<option value='".$row["NUM_DISCIPLINE"]."' ";	
    		if(isset ($_POST['discipline']) && ($row["NUM_DISCIPLINE"]==$_POST['discipline']))  echo ' selected="selected" ';
    		echo ">".$txt."</option>";
    	}
    	echo "</select>";
     
     
    	if (isset ($_POST['discipline'])) {
     
    		$comite="select NUM_COMITE, NOM_COMITE FROM COMITE, LIGUE, FEDERATION, DISCIPLINE WHERE comite.num_ligue=ligue.num_ligue AND federation.num_federation=discipline.num_federation AND ligue.num_federation=federation.num_federation AND discipline.num_discipline=".$_POST['discipline'];
    		$reqcomite=mysql_query($comite)or die(mysql_error());
    		echo "<select name='comite' onchange='form.submit()'><option value=''>-- Selectionnez --</option>";
    		while ($row=mysql_fetch_array($reqcomite))
    		{
    			$txt=Tronquer_Texte($row["NOM_COMITE"], $longeur_max);
    			echo "<option value='".$row["NUM_COMITE"]."' ";
    			if(isset ($_POST['comite']) && ($row["NUM_COMITE"]==$_POST['comite']))  echo ' selected="selected" ';
    			echo ">".$txt."</option>";
    		}
    		echo "</select>";	
     
    		if (isset ($_POST['comite'])) {
     
    			$club="select NUM_CLUB, NOM_CLUB FROM CLUB WHERE club.num_comite=".$_POST['comite'];
    			$reqclub=mysql_query($club)or die(mysql_error());
    			echo "<select name='club'><option value=''>-- Selectionnez --</option>";
    			while ($row=mysql_fetch_array($reqclub))
    			{
    				$txt=Tronquer_Texte($row["NOM_CLUB"], $longeur_max);
    				echo "<option value='".$row["NUM_COMITE"]."'>".$txt."</option>";				 					
    			}
    			echo "</select>";
    			echo "<input type='submit' value='Valider'>";
     		}
    	}
     
    //fermeture du formulaire
    echo "</form>";
     
    // Si encadrement, fonction et club existent et sont non vides
    if (isset ($_POST['encadrement'] , $_POST['fonction'] , $_POST['club']) && !empty($_POST['encadrement']) && !empty($_POST['fonction']) && !empty($_POST['club']) ) {
     
    									$sql="select NUM_CLUB, NUM_ENCADREMENT, NUM_FONCTION from ENCADRER_CLUB where NUM_CLUB=".$_POST['club']." AND NUM_ENCADREMENT= ".$_POST['encadrement']." AND NUM_FONCTION= " .$_POST['fonction'];
    									$query=mysql_query($sql);
    									$nbnum=mysql_num_rows($query);
     
    									$reqclub="select NOM_CLUB from club where NUM_CLUB=".$_POST['club'];
    									$club=mysql_query($reqclub) or die (mysql_error());
    									$row=mysql_fetch_array($club);
    									if ($nbnum!=NULL)
    									{
    										echo "CLub <b>".$row['NOM_CLUB']."</b> déjà selectionné pour cette personne<br><br>";
    									}
    									else
    									{
    										$insert="insert into ENCADRER_CLUB values('".$_POST['encadrement']."','".$_POST['fonction']."','".$_POST['club']."')";
    $query=mysql_query($insert) or die ($insert.' : '.mysql_error());
     
    										echo "Insertion Réussie pour le comite <b>".$row['NOM_CLUB']."</b><br>";
     
    									}
    								}
    								else
    								{
    								echo "<b>ERREUR REQUETE</b>";
    								}

  2. #62
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    BOn, d'accord A force de faire du ménage dans ton code j'ai supprimé des trucs induspenseables
    IL manque les fermetures des 2 premiers select. (je remets tout le code histoire qu'on s'embrouille pas plus )
    Code php : 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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
     
    <? require "Includes/fonctions.php"; ?>
    <?
    //ouverture du formulaire
    echo "<form action='' method='post' name='form'>";
     ?>
    <div class="titre">Selectionnez la personne</div>
     
    <?
    	//liste des personnes de l'encadrement
     
    	$reqmvt="select NOM_ENCADREMENT, PRENOM_ENCADREMENT, NUM_ENCADREMENT from ENCADREMENT order by NOM_ENCADREMENT";
    	$mvt=mysql_query($reqmvt)or die(mysql_error());
    	echo "<select name='encadrement'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$nom=strtoupper($row["NOM_ENCADREMENT"]);
    		$prenom=strtolower($row["PRENOM_ENCADREMENT"]);
    		$prenom=ucfirst($prenom);
    		echo "<option value='".$row['NUM_ENCADREMENT']."' ";
    		if (isset ($_POST['encadrement']) && $_POST['encadrement']==$row['NUM_ENCADREMENT']) echo " selected ";
    		echo "'>".$nom."&nbsp;&nbsp;".$prenom."</option>";
    	}
    echo "</select>";
    	if( isset($_POST['personne']) ) echo '<input type="hidden" name="personne" value="' .$_POST['personne']. '"/>';
     
    ?>
     
    <div class="titre">Selectionnez sa fonction</div>
    <?
    	//liste des fonctions
     
    	$reqfonction="select LIB_FONCTION, NUM_FONCTION from FONCTION order by LIB_FONCTION";
    	$fonction=mysqlquery($reqfonction) or die (mysql_error());
    	echo "<select name='fonction'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($fonction))
    	{
    		echo '<option value="'.$val['NUM_FONCTION'].'" ';
    		if (isset ($_POST['focntion']) && $_POST['fonction']==$row['NUM_FONCTION']) echo " selected ";
    		echo '">'.$val['LIB_FONCTION'].'</option>';
    	}
    echo "</select>";	
    ?>
     
    <hr width="100%"><div class="titre">Selectionnez la discipline</div>
    <?
     
     
    	$reqmvt="select NUM_DISCIPLINE, NOM_DISCIPLINE from DISCIPLINE order by NOM_DISCIPLINE";
    	$mvt=mysql_query($reqmvt);
    	echo "<select name='discipline' onchange='form.submit()'>";
    	echo "<option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$txt=Tronquer_Texte($row["NOM_DISCIPLINE"], $longeur_max);
    		echo "<option value='".$row["NUM_DISCIPLINE"]."' ";	
    		if(isset ($_POST['discipline']) && ($row["NUM_DISCIPLINE"]==$_POST['discipline']))  echo ' selected="selected" ';
    		echo ">".$txt."</option>";
    	}
    	echo "</select>";
     
     
    	if (isset ($_POST['discipline'])) {
     
    		$comite="select NUM_COMITE, NOM_COMITE FROM COMITE, LIGUE, FEDERATION, DISCIPLINE WHERE comite.num_ligue=ligue.num_ligue AND federation.num_federation=discipline.num_federation AND ligue.num_federation=federation.num_federation AND discipline.num_discipline=".$_POST['discipline'];
    		$reqcomite=mysql_query($comite)or die(mysql_error());
    		echo "<select name='comite' onchange='form.submit()'><option value=''>-- Selectionnez --</option>";
    		while ($row=mysql_fetch_array($reqcomite))
    		{
    			$txt=Tronquer_Texte($row["NOM_COMITE"], $longeur_max);
    			echo "<option value='".$row["NUM_COMITE"]."' ";
    			if(isset ($_POST['comite']) && ($row["NUM_COMITE"]==$_POST['comite']))  echo ' selected="selected" ';
    			echo ">".$txt."</option>";
    		}
    		echo "</select>";	
     
    		if (isset ($_POST['comite'])) {
     
    			$club="select NUM_CLUB, NOM_CLUB FROM CLUB WHERE club.num_comite=".$_POST['comite'];
    			$reqclub=mysql_query($club)or die(mysql_error());
    			echo "<select name='club'><option value=''>-- Selectionnez --</option>";
    			while ($row=mysql_fetch_array($reqclub))
    			{
    				$txt=Tronquer_Texte($row["NOM_CLUB"], $longeur_max);
    				echo "<option value='".$row["NUM_COMITE"]."'>".$txt."</option>";				 					
    			}
    			echo "</select>";
    			echo "<input type='submit' value='Valider'>";
     		}
    	}
     
    //fermeture du formulaire
    echo "</form>";
     
    // Si encadrement, fonction et club existent et sont non vides
    if (isset ($_POST['encadrement'] , $_POST['fonction'] , $_POST['club']) && !empty($_POST['encadrement']) && !empty($_POST['fonction']) && !empty($_POST['club']) ) {
     
    									$sql="select NUM_CLUB, NUM_ENCADREMENT, NUM_FONCTION from ENCADRER_CLUB where NUM_CLUB=".$_POST['club']." AND NUM_ENCADREMENT= ".$_POST['encadrement']." AND NUM_FONCTION= " .$_POST['fonction'];
    									$query=mysql_query($sql);
    									$nbnum=mysql_num_rows($query);
     
    									$reqclub="select NOM_CLUB from club where NUM_CLUB=".$_POST['club'];
    									$club=mysql_query($reqclub) or die (mysql_error());
    									$row=mysql_fetch_array($club);
    									if ($nbnum!=NULL)
    									{
    										echo "CLub <b>".$row['NOM_CLUB']."</b> déjà selectionné pour cette personne<br><br>";
    									}
    									else
    									{
    										$insert="insert into ENCADRER_CLUB values('".$_POST['encadrement']."','".$_POST['fonction']."','".$_POST['club']."')";
    $query=mysql_query($insert) or die ($insert.' : '.mysql_error());
     
    										echo "Insertion Réussie pour le comite <b>".$row['NOM_CLUB']."</b><br>";
     
    									}
    								}
    								else
    								{
    								echo "<b>ERREUR REQUETE</b>";
    								}

  3. #63
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    ca marche toujours pas, j'ai des trucs louches à l'écran

    Il affiche

    Selectionnez la personne
    DAns la liste il y a
    --Selectionnez--
    ligne blanche
    --Selectionnez
    Choix de la discipline

    fin de la liste

    à coté de cette liste il y a

    --Selectionnez--

    un ligne de pointillés et

    ERREUR REQUETE

  4. #64
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    Aidez moi c'est super important pour mon stage.

  5. #65
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Encore un problème de ponctuation
    Cette fois j'espère que ça va marcher !
    Code php : 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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    <? require "Includes/fonctions.php"; ?>
    <?
    //ouverture du formulaire
    echo "<form action='' method='post' name='form'>";
     ?>
    <div class="titre">Selectionnez la personne</div>
     
    <?
    	//liste des personnes de l'encadrement
     
    	$reqmvt="select NOM_ENCADREMENT, PRENOM_ENCADREMENT, NUM_ENCADREMENT from ENCADREMENT order by NOM_ENCADREMENT";
    	$mvt=mysql_query($reqmvt)or die(mysql_error());
    	echo "<select name='encadrement'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$nom=strtoupper($row["NOM_ENCADREMENT"]);
    		$prenom=strtolower($row["PRENOM_ENCADREMENT"]);
    		$prenom=ucfirst($prenom);
    		echo "<option value='".$row['NUM_ENCADREMENT']."' ";
    		if (isset ($_POST['encadrement']) && $_POST['encadrement']==$row['NUM_ENCADREMENT']) echo " selected ";
    		echo ">".$nom."&nbsp;&nbsp;".$prenom."</option>";
    	}
    	echo "</select>";
    	if( isset($_POST['personne']) ) echo '<input type="hidden" name="personne" value="' .$_POST['personne']. '"/>';
     
    ?>
     
    <div class="titre">Selectionnez sa fonction</div>
    <?
    	//liste des fonctions
     
    	$reqfonction="select LIB_FONCTION, NUM_FONCTION from FONCTION order by LIB_FONCTION";
    	$fonction=mysqlquery($reqfonction) or die (mysql_error());
    	echo "<select name='fonction'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($fonction))
    	{
    		echo '<option value="'.$val['NUM_FONCTION'].'" ';
    		if (isset ($_POST['focntion']) && $_POST['fonction']==$row['NUM_FONCTION']) echo " selected ";
    		echo '>'.$val['LIB_FONCTION'].'</option>';
    	}
    	echo "</select>";	
    ?>
     
    <hr width="100%"><div class="titre">Selectionnez la discipline</div>
    <?
     
     
    	$reqmvt="select NUM_DISCIPLINE, NOM_DISCIPLINE from DISCIPLINE order by NOM_DISCIPLINE";
    	$mvt=mysql_query($reqmvt);
    	echo "<select name='discipline' onchange='form.submit()'>";
    	echo "<option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$txt=Tronquer_Texte($row["NOM_DISCIPLINE"], $longeur_max);
    		echo "<option value='".$row["NUM_DISCIPLINE"]."' ";	
    		if(isset ($_POST['discipline']) && ($row["NUM_DISCIPLINE"]==$_POST['discipline']))  echo ' selected="selected" ';
    		echo ">".$txt."</option>";
    	}
    	echo "</select>";
     
     
    	if (isset ($_POST['discipline'])) {
     
    		$comite="select NUM_COMITE, NOM_COMITE FROM COMITE, LIGUE, FEDERATION, DISCIPLINE WHERE comite.num_ligue=ligue.num_ligue AND federation.num_federation=discipline.num_federation AND ligue.num_federation=federation.num_federation AND discipline.num_discipline=".$_POST['discipline'];
    		$reqcomite=mysql_query($comite)or die(mysql_error());
    		echo "<select name='comite' onchange='form.submit()'><option value=''>-- Selectionnez --</option>";
    		while ($row=mysql_fetch_array($reqcomite))
    		{
    			$txt=Tronquer_Texte($row["NOM_COMITE"], $longeur_max);
    			echo "<option value='".$row["NUM_COMITE"]."' ";
    			if(isset ($_POST['comite']) && ($row["NUM_COMITE"]==$_POST['comite']))  echo ' selected="selected" ';
    			echo ">".$txt."</option>";
    		}
    		echo "</select>";	
     
    		if (isset ($_POST['comite'])) {
     
    			$club="select NUM_CLUB, NOM_CLUB FROM CLUB WHERE club.num_comite=".$_POST['comite'];
    			$reqclub=mysql_query($club)or die(mysql_error());
    			echo "<select name='club'><option value=''>-- Selectionnez --</option>";
    			while ($row=mysql_fetch_array($reqclub))
    			{
    				$txt=Tronquer_Texte($row["NOM_CLUB"], $longeur_max);
    				echo "<option value='".$row["NUM_COMITE"]."'>".$txt."</option>";				 					
    			}
    			echo "</select>";
    			echo "<input type='submit' name='inserer' value='Valider'>";
     		}
    	}
     
    //fermeture du formulaire
    echo "</form>";
     
    // Si encadrement, fonction et club existent et sont non vides
    if (isset ($_POST['encadrement'] , $_POST['fonction'] , $_POST['club']) && !empty($_POST['encadrement']) && !empty($_POST['fonction']) && !empty($_POST['club']) ) 
    {
     
    	$sql="select NUM_CLUB, NUM_ENCADREMENT, NUM_FONCTION from ENCADRER_CLUB where NUM_CLUB=".$_POST['club']." AND NUM_ENCADREMENT= ".$_POST['encadrement']." AND NUM_FONCTION= " .$_POST['fonction'];
    	$query=mysql_query($sql);
    	$nbnum=mysql_num_rows($query);
     
    	$reqclub="select NOM_CLUB from club where NUM_CLUB=".$_POST['club'];
    	$club=mysql_query($reqclub) or die (mysql_error());
    	$row=mysql_fetch_array($club);
    	if ($nbnum!=NULL)
    	{
    		echo "CLub <b>".$row['NOM_CLUB']."</b> déjà selectionné pour cette personne<br><br>";
    	}
    	else
    	{
    		$insert="insert into ENCADRER_CLUB values('".$_POST['encadrement']."','".$_POST['fonction']."','".$_POST['club']."')";
    		$query=mysql_query($insert) or die ($insert.' : '.mysql_error());
     		echo "Insertion Réussie pour le comite <b>".$row['NOM_CLUB']."</b><br>";
    	}
    }

  6. #66
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    C'est de mieux en mieux.
    La liste encadrement est remplie.
    La liste fonction est vide (enfin juste --Selectionnez--)
    La liste discipline contient exclusivement ... en je ne sais pas combien de lignes

  7. #67
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Bon, je vois pas d'erreur dans la liste fonction. (tu es sûre que la table n'est pas vide, je suppose) Au cas où, juste le code de la partie fonction à remplacer :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <div class="titre">Selectionnez sa fonction</div>
    <?
    	//liste des fonctions
    	echo "<select name='fonction'><option value=''>-- Selectionnez --</option>"; 
    	$reqfonction="select LIB_FONCTION, NUM_FONCTION from FONCTION order by LIB_FONCTION";
    	$fonction=mysqlquery($reqfonction) or die (mysql_error());
    	while ($row=mysql_fetch_array($fonction))
    	{
    		echo "<option value='".$row['NUM_FONCTION']."' ";
    		if (isset ($_POST['fonction']) && $_POST['fonction']==$row['NUM_FONCTION']) echo " selected ";
    		echo ">".$row['LIB_FONCTION']."</option>";
    	}
    	echo "</select>";	
    ?>

    Pour la liste discipline, ça vient peut-être de TronquerTexte(). Quel est le code de cette fonction ?

  8. #68
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    function Tronquer_Texte($txt, $longeur_max)
    {
    	if (strlen($txt) > $longeur_max)
    	{
    	$txt = substr($txt, 0, $longeur_max);
    	$dernier_espace = strrpos($txt, " ");
    	$txt = substr($txt, 0, $dernier_espace)."...";
    	}
    return $txt;
    }
    Je pense que longueur max n'est pas définie.

  9. #69
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Effectivement ça doit venir de là. Dans ce cas, ajoute un définition de $longueur_max en début de script.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <? require "Includes/fonctions.php"; ?>
    <?
    // on ajoute ICI la longueur max
    $longueur_max=15;
    //ouverture du formulaire
    echo "<form action='' method='post' name='form'>";
     ?>

  10. #70
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    Tout va bien sauf mon insert

    Quand je clique sur valider il ne se passe rien.

  11. #71
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Rien du tout ?
    Bon cette fois le problème doit être dans la partie de l'insert...
    Ajoute un print_r($_POST) après tout le reste et dis-moi ce qu'il renvoie une fois que tu as cliqué sur valider.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    // tout le code déjà écrit
    print_r($_POST);
    ?>

  12. #72
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    Voila ce que me renvoie print_r($_POST); après avoir cliquer sur valider

    Array ( [encadrement] => 24 [fonction] => 2 [discipline] => 130 [comite] => 70 [club] => [inserer] => Valider )

  13. #73
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Donc il n'ya rien dans la variable club...
    *celira re-re-re-lit le code*
    Ah oui, c'est normal, on lui demande la valeur de num_comite
    Dans le code de la liste club (dans le isset($_POST['comite']), remplace
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $txt=Tronquer_Texte($row["NOM_CLUB"], $longeur_max);
    echo "<option value='".$row["NUM_COMITE"]."'>".$txt."</option>";
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $txt=Tronquer_Texte($row["NOM_CLUB"], $longeur_max);
    echo "<option value='".$row["NUM_CLUB"]."'>".$txt."</option>";

  14. #74
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    C'est bon, tout fonctionne, mon tuteur de stage est super content.

    MERCI Celira

  15. #75
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Tant mieux !
    J'ai cru un momement qu'on n'y arriverait pas ça nous aura quand même pris 75 posts...

  16. #76
    Débutant
    Technicien maintenance
    Inscrit en
    Mai 2007
    Messages
    123
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mai 2007
    Messages : 123
    Points : 37
    Points
    37
    Par défaut
    Voila le code final :

    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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    <? require "Includes/fonctions.php"; ?>
    <?
    //ouverture du formulaire
    echo "<form action='' method='post' name='form'>";
    $longeur_max=60;
     ?>
    <div class="titre">Selectionnez la personne</div>
     
    <?
     
    	//liste des personnes de l'encadrement
     
    	$reqmvt="select NOM_ENCADREMENT, PRENOM_ENCADREMENT, NUM_ENCADREMENT from ENCADREMENT order by NOM_ENCADREMENT";
    	$mvt=mysql_query($reqmvt)or die(mysql_error());
    	echo "<select name='encadrement'><option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$nom=strtoupper($row["NOM_ENCADREMENT"]);
    		$prenom=strtolower($row["PRENOM_ENCADREMENT"]);
    		$prenom=ucfirst($prenom);
    		echo "<option value='".$row['NUM_ENCADREMENT']."' ";
    		if (isset ($_POST['encadrement']) && $_POST['encadrement']==$row['NUM_ENCADREMENT']) echo " selected ";
    		echo ">".$nom."&nbsp;&nbsp;".$prenom."</option>";
    	}
    	echo "</select>";
    	if( isset($_POST['personne']) ) echo '<input type="hidden" name="personne" value="' .$_POST['personne']. '"/>';
     
    ?>
     
    <div class="titre">Selectionnez sa fonction</div>
    <?
    	//liste des fonctions
    	echo "<select name='fonction'><option value=''>-- Selectionnez --</option>"; 
    	$reqfonction="select LIB_FONCTION, NUM_FONCTION from FONCTION order by LIB_FONCTION";
    	$fonction=mysql_query($reqfonction) or die (mysql_error());
    	while ($row=mysql_fetch_array($fonction))
    	{
    		echo "<option value='".$row['NUM_FONCTION']."' ";
    		if (isset ($_POST['fonction']) && $_POST['fonction']==$row['NUM_FONCTION']) echo " selected ";
    		echo ">".$row['LIB_FONCTION']."</option>";
    	}
    	echo "</select>";	
    ?>
     
    <hr width="100%"><div class="titre">Selectionnez la discipline</div>
    <?
     
     
    	$reqmvt="select NUM_DISCIPLINE, NOM_DISCIPLINE from DISCIPLINE order by NOM_DISCIPLINE";
    	$mvt=mysql_query($reqmvt);
    	echo "<select name='discipline' onchange='form.submit()'>";
    	echo "<option value=''>-- Selectionnez --</option>";
    	while ($row=mysql_fetch_array($mvt))
    	{
    		$txt=Tronquer_Texte($row["NOM_DISCIPLINE"], $longeur_max);
    		echo "<option value='".$row["NUM_DISCIPLINE"]."' ";	
    		if(isset ($_POST['discipline']) && ($row["NUM_DISCIPLINE"]==$_POST['discipline']))  echo ' selected="selected" ';
    		echo ">".$txt."</option>";
    	}
    	echo "</select>";
     
     
    	if (isset ($_POST['discipline'])) {
     
    		$comite="select NUM_COMITE, NOM_COMITE FROM COMITE, LIGUE, FEDERATION, DISCIPLINE WHERE comite.num_ligue=ligue.num_ligue AND federation.num_federation=discipline.num_federation AND ligue.num_federation=federation.num_federation AND discipline.num_discipline=".$_POST['discipline'];
    		$reqcomite=mysql_query($comite)or die(mysql_error());
    		echo "<select name='comite' onchange='form.submit()'><option value=''>-- Selectionnez --</option>";
    		while ($row=mysql_fetch_array($reqcomite))
    		{
    			$txt=Tronquer_Texte($row["NOM_COMITE"], $longeur_max);
    			echo "<option value='".$row["NUM_COMITE"]."' ";
    			if(isset ($_POST['comite']) && ($row["NUM_COMITE"]==$_POST['comite']))  echo ' selected="selected" ';
    			echo ">".$txt."</option>";
    		}
    		echo "</select>";	
     
    		if (isset ($_POST['comite'])) {
     
    			$club="select NUM_CLUB, NOM_CLUB FROM CLUB WHERE club.num_comite=".$_POST['comite'];
    			$reqclub=mysql_query($club)or die(mysql_error());
    			echo "<select name='club'><option value=''>-- Selectionnez --</option>";
    			while ($row=mysql_fetch_array($reqclub))
    			{
    				$txt=Tronquer_Texte($row["NOM_CLUB"], $longeur_max);
    				echo "<option value='".$row["NUM_CLUB"]."'>".$txt."</option>";				 					
    			}
    			echo "</select>";
    			echo "<input type='submit' name='inserer' value='Valider'>";
     		}
    	}
     
    //fermeture du formulaire
    echo "</form>";
     
    // Si encadrement, fonction et club existent et sont non vides
    if (isset ($_POST['encadrement'] , $_POST['fonction'] , $_POST['club']) && !empty($_POST['encadrement']) && !empty($_POST['fonction']) && !empty($_POST['club']) ) 
    {
     
    	$sql="select NUM_CLUB, NUM_ENCADREMENT, NUM_FONCTION from ENCADRER_CLUB where NUM_CLUB=".$_POST['club']." AND NUM_ENCADREMENT= ".$_POST['encadrement']." AND NUM_FONCTION= " .$_POST['fonction'];
    	$query=mysql_query($sql);
    	$nbnum=mysql_num_rows($query);
     
    	$reqclub="select NOM_CLUB from club where NUM_CLUB=".$_POST['club'];
    	$club=mysql_query($reqclub) or die (mysql_error());
    	$row=mysql_fetch_array($club);
    	if ($nbnum!=NULL)
    	{
    		echo "Club <b>".$row['NOM_CLUB']."</b> déjà selectionné pour cette personne<br><br>";
    	}
    	else
    	{
    		$insert="insert into ENCADRER_CLUB values('".$_POST['encadrement']."','".$_POST['club']."','".$_POST['fonction']."')";
    		$query=mysql_query($insert) or die ($insert.' : '.mysql_error());
     		echo "Insertion Réussie pour le club <b>".$row['NOM_CLUB']."</b><br>";
    	}
    }

+ Répondre à la discussion
Cette discussion est résolue.
Page 4 sur 4 PremièrePremière 1234

Discussions similaires

  1. Réponses: 1
    Dernier message: 13/04/2015, 11h17
  2. Réponses: 8
    Dernier message: 22/12/2014, 20h58
  3. Réponses: 6
    Dernier message: 02/06/2010, 09h40
  4. Présélectionner une valeur par défaut dans liste déroulante
    Par kate59 dans le forum PHP & Base de données
    Réponses: 12
    Dernier message: 25/07/2009, 22h52
  5. Recherche une valeur d'une cellule dans une colonne d'une autre feuille
    Par kourria dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 21/06/2007, 13h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo