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 :

récupération des données


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    53
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 53
    Par défaut récupération des données
    Bonjour,

    Je dois faire un formulaire contenant un tableau du type ci dessous

    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
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
     
    <!-------------------------*QUESTION 7--------------------->
     
    <p class="soustitrenoir">7 - Concernant ces demandes, pouvez vous renseigner le tableau suivant ? <span class="soustitrerouge">&curren;</span></p>
    <table border="1" cellpadding="0" cellspacing="2" bgcolor="#CCCCCC">
       <tr>
        <td class="texte"><center><b>Numéro attribué<br> à la personne<br> (voir à la question 1) </b></center></td>
    	<td class="texte"><center><b>La demande a-t-elle aboutit <br> (oui/non) </center></b></td>
    	<td class="texte"><center><b>Si non : motif du refus évoqué par l'établissement pour personnes âgées</center></b></td>
      </tr>
        <!--LIGNE 1-->
      <tr>
          <td><textarea name="q7num_1" cols="22" rows="5 " id="num_1" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px"><?php
            if (!empty($_POST["q7num_1"])) { 
     
                    echo htmlspecialchars($_POST["q7num_1"],ENT_QUOTES);
            }
            ?></textarea>
    	   </td>
     
    	   <td class="texte">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oui
    	   <input name="q7dmd_1" type="radio" value="oui" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;font-family: Verdana; font-size:10px"<?php
            if (!empty($_POST["q7dmd_1"])) { 
                    $q7dmd_1 = $_POST["q7dmd_1"];
    				if ($q7dmd_1 =="oui") { echo " checked"; }
            }
    		else {
    				$q7dmd_1 = "";
    		}
             ?>>
        <span class="texte">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;non</span>
    	<input name="q7dmd_1" type="radio" value="non" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px"<?php
            if (!empty($_POST["q7dmd_1"])) { 
                    $q7dmd_1 = $_POST["q7dmd_1"];
    				if ($q7dmd_1 =="non") { echo " checked"; }
            }
    		else {
    				$q7dmd_1 = "";
    		}
     
        ?>></td>
     
     
        <td>
    	<input name="q7non_1" type="checkbox" id="q7non_1" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="mq_place"<?php
            if (!empty($_POST["q7non_1"])) { 
                    $q7non_1 = $_POST["q7non_1"];
    				if ($q7non_1 =="mq_place") { echo " checked"; }
            }
    		else {
    				$q7non_1 = "";
    		}
             ?>><span class="texte">Manque de place</span>
    		  <br>
        <input name="q7non_3" type="checkbox" id="q7non_3" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="pb_financ"<?php
            if (!empty($_POST["q7non_3"])) { 
                    $q7non_3 = $_POST["q7non_3"];
    				if ($q7non_3 =="pb_financ") { echo " checked"; }
            }
    		else {
    				$q7non_3 = "";
    		}
             ?>><span class="texte">Problèmes financiers</span>
    		 <br>
     
        <input name="q7non_2" type="checkbox" id="q7non_2" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="patho"<?php
            if (!empty($_POST["q7non_2"])) { 
                    $q7non_2 = $_POST["q7non_2"];
    				if ($q7non_2 =="patho") { echo " checked"; }
            }
    		else {
    				$q7non_2 = "";
    		}
             ?>><span class="texte">Pathologogie ou déficience incompatible avec prise en charge en maison de retraite </span>
        <br>
     
        <input name="q7non_3" type="checkbox" id="q7non_3" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="autre"<?php
            if (!empty($_POST["q7non_3"])) { 
                    $q7non_3 = $_POST["q7non_3"];
    				if ($q7non_3 =="autre") { echo " checked"; }
            }
    		else {
    				$q7non_3 = "";
    		}
             ?>><span class="texte">Autres</span>
    		 <span class="texte">(Préciser) :</span>
    		 <input name="q7non_autre" type="text" id="q7non_autre" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;
         font-family: Verdana; font-size:10px" size="70" maxlength="70" value="<?php
            if (!empty($_POST["q7non_autre"])) { 
     
                    echo htmlspecialchars($_POST["q7non_autre"],ENT_QUOTES);
            }
            ?>"></td>		 
     
     
    	</td>
      </tr>
      <!--LIGNE 2-->
        <tr>
          <td><textarea name="q7num_1" cols="22" rows="5 " id="num_1" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px"><?php
            if (!empty($_POST["q7num_1"])) { 
     
                    echo htmlspecialchars($_POST["q7num_1"],ENT_QUOTES);
            }
            ?></textarea>
    	   </td>
     
    	   <td class="texte">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oui
    	   <input name="q7dmd_1" type="radio" value="oui" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;font-family: Verdana; font-size:10px"<?php
            if (!empty($_POST["q7dmd_1"])) { 
                    $q7dmd_1 = $_POST["q7dmd_1"];
    				if ($q7dmd_1 =="oui") { echo " checked"; }
            }
    		else {
    				$q7dmd_1 = "";
    		}
             ?>>
        <span class="texte">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;non</span>
    	<input name="q7dmd_1" type="radio" value="non" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px"<?php
            if (!empty($_POST["q7dmd_1"])) { 
                    $q7dmd_1 = $_POST["q7dmd_1"];
    				if ($q7dmd_1 =="non") { echo " checked"; }
            }
    		else {
    				$q7dmd_1 = "";
    		}
     
        ?>></td>
     
     
        <td>
    	<input name="q7non_1" type="checkbox" id="q7non_1" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="mq_place"<?php
            if (!empty($_POST["q7non_1"])) { 
                    $q7non_1 = $_POST["q7non_1"];
    				if ($q7non_1 =="mq_place") { echo " checked"; }
            }
    		else {
    				$q7non_1 = "";
    		}
             ?>><span class="texte">Manque de place</span>
    		  <br>
        <input name="q7non_3" type="checkbox" id="q7non_3" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="pb_financ"<?php
            if (!empty($_POST["q7non_3"])) { 
                    $q7non_3 = $_POST["q7non_3"];
    				if ($q7non_3 =="pb_financ") { echo " checked"; }
            }
    		else {
    				$q7non_3 = "";
    		}
             ?>><span class="texte">Problèmes financiers</span>
    		 <br>
     
        <input name="q7non_2" type="checkbox" id="q7non_2" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="patho"<?php
            if (!empty($_POST["q7non_2"])) { 
                    $q7non_2 = $_POST["q7non_2"];
    				if ($q7non_2 =="patho") { echo " checked"; }
            }
    		else {
    				$q7non_2 = "";
    		}
             ?>><span class="texte">Pathologogie ou déficience incompatible avec prise en charge en maison de retraite </span>
        <br>
     
        <input name="q7non_3" type="checkbox" id="q7non_3" style="background-color:#000000; color:#FFFFFF; border:1px #92A6B4 solid ;
    font-family: Verdana; font-size:10px" value="autre"<?php
            if (!empty($_POST["q7non_3"])) { 
                    $q7non_3 = $_POST["q7non_3"];
    				if ($q7non_3 =="autre") { echo " checked"; }
            }
    		else {
    				$q7non_3 = "";
    		}
             ?>><span class="texte">Autres</span>
    		 <span class="texte">(Préciser) :</span>
    		 <input name="q7non_autre" type="text" id="q7non_autre" style="background-color:#FFFFFF; color:#000000; border:1px #92A6B4 solid ;
         font-family: Verdana; font-size:10px" size="70" maxlength="70" value="<?php
            if (!empty($_POST["q7non_autre"])) { 
     
                    echo htmlspecialchars($_POST["q7non_autre"],ENT_QUOTES);
            }
            ?>"></td>		 
     
     
    	</td>
      </tr>
    </table>
    J'aimerais que la personne ajoute autant de lignes que nécessaire et ensuite comment faire pour les enregistrer dans la base de donées my sql sachant que je ne vais pas créer 50 champs supplémentaires alors que j'en aurai peut-être que 40 ??

    Pouvez vous m'aider.

    Merci

  2. #2
    Membre émérite
    Profil pro
    Assistant recherche bioinformatique
    Inscrit en
    Novembre 2007
    Messages
    877
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Assistant recherche bioinformatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 877
    Par défaut
    Bonjour,
    Es-ce toi qui a écrit ce code ?
    Qu'est ce qui cloche exactement ?
    Tu penses utiliser quoi pour ajouter tes lignes : javascript ou php ?

    Concernant la recuperation des données d'un formulaire, sache que tu peux specifié des nomes avec des [] (par exemple : demande_abouti[]). Ensuite, dans php, tu recupere ta variable qui est en faite un tableau de données. Ainsi, tu n'as tes variables d'une ligne multiplier par toute les lignes, mais des variables tableaux, autant d'element que de ligne.
    Je te laisse imaginer les possibilités dans ton exercice.

    Z.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    53
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 53
    Par défaut
    Bonjour Z,

    Oui c'est une partie de mon code en bidouillant car pas forte en php javascript

    Je pense utiliser javascript avec un bouton ajoutant des lignes;

    Je vais rechercher encore un peu merci pour ta réponse

  4. #4
    Membre émérite
    Profil pro
    Assistant recherche bioinformatique
    Inscrit en
    Novembre 2007
    Messages
    877
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Assistant recherche bioinformatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 877
    Par défaut
    Hesite pas a venir poster tes idées ici.
    Si tu buttes, on te donnera un coup de main, que ca soit javascript ou php !

    Je vais essayer de simplifier mon conseil si dessus :
    ecrit une ligne de ton tableau en HTML, avec nom de variable 'normal'.
    Apres, tu rajoutes des crochets a la suite de chaque champ de cette ligne.
    Tu obtiens ta vrai ligne.
    Puis tu utilises javascript pour rajouter des lignes.
    Et pour finir, tu recuperes des tableaux de données via php lors dela soumission du formulaire.

    Z.

  5. #5
    Membre éclairé Avatar de BenoitDenis
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    536
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Sarthe (Pays de la Loire)

    Informations forums :
    Inscription : Avril 2005
    Messages : 536
    Par défaut
    Elle posait également le probleme de stocker dans la bdd, et la je suis pas sur qu'on puisse stocker un tableau si ?

  6. #6
    Membre émérite
    Profil pro
    Assistant recherche bioinformatique
    Inscrit en
    Novembre 2007
    Messages
    877
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Assistant recherche bioinformatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 877
    Par défaut
    non, mais tu parcours ton tableau, sachant que 1 index correspondrait a une ligne du tableau html/formulaire.

  7. #7
    Modérateur
    Avatar de Vil'Coyote
    Homme Profil pro
    Développeur adélia & Web
    Inscrit en
    Février 2008
    Messages
    4 583
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur adélia & Web
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2008
    Messages : 4 583
    Par défaut
    Citation Envoyé par schlough Voir le message
    Elle posait également le probleme de stocker dans la bdd, et la je suis pas sur qu'on puisse stocker un tableau si ?
    un tableau? on peut stocker le code html si on le souhaites
    mais bon, je pense que si l'on souhaite rendre cela pérène et surtout valable pour tout le monde le mieux serait une table personne, formulaire, element_formulaire

    une personne pouvant créer 1 à x formulaire, chaque formulaire pouvant avoir 1 à x éléments.

    mais bon c'est qu'une idée.
    la vie n'est pas cirrhose des foies ...

    Avant de poster un message Rechercher n'est pas qu'une option.
    FAQ Web - Tuto Web

Discussions similaires

  1. Récupération des données d'un formulaire
    Par placenargac dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 04/02/2006, 15h10
  2. récupération des données via une liste déroulante
    Par rahan_dave dans le forum Access
    Réponses: 1
    Dernier message: 13/10/2005, 12h27
  3. [HTML][FORMULAIRE] Probleme dans la récupération des données
    Par baddounet dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 15/08/2005, 18h51
  4. Réponses: 2
    Dernier message: 20/02/2004, 08h47
  5. Réponses: 13
    Dernier message: 20/03/2003, 08h11

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