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

Langage PHP Discussion :

Formulaire


Sujet :

Langage PHP

  1. #1
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut Formulaire
    je veux faire plusieurs select dans un formulaire pour sélectionner plusieurs produits.
    Chaque ligne de mon tableau affiche le select et des elements (prix, quantité ..) extrait d'une base.
    ça marche pour le premier produit mais Je n'arrive pas à gérer ça pour plusieurs lignes.

  2. #2
    Membre du Club
    Inscrit en
    Juin 2004
    Messages
    100
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 100
    Points : 64
    Points
    64
    Par défaut
    un tit peu de code serait une bonne idée pour pouvoir t aider non ?
    Pense a enlever les mdp

  3. #3
    Membre averti Avatar de ShinJava
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    413
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 413
    Points : 357
    Points
    357
    Par défaut
    Va falloir que tu nous montres ton code concernant ton prob, afin de t'aider au mieux ^^

    ++
    ShinJava


    edit : grilled !

  4. #4
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    Voici un l'extrait du code concernant mon problème.
    C'est un développement dans Oscommerce et de nombreuses fonctions spécifiques sont employés. Mon code est donc difficilement testable en dehors de son contexte. Par contre il montrera sans doute une ou des erreurs grossières dans mon code. Quand on s'ennerve dessus on voit plus rien.


    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
    // mise à jour table products_bundles
    if (tep_not_null($action)) {
    if ($action == 'choix')
    {
    $products_name_query = tep_db_query("select products_model, products_tarif_ha_ht_last, products_quantity, products_cptp, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
    while ($products_req = tep_db_fetch_array($products_name_query))
    {$products_model[] = $products_req['products_model'] ;
    $products_tarif_ha_ht_last[] = $products_req['products_tarif_ha_ht_last'] ;
    $products_cptp[] = $products_req['products_cptp'] ;
    $products_quantity[] = $products_req['products_quantity'] ;
    $products_price[] = $products_req['products_price'] ;
    }
    }
    }
    ?>

    <!-- tableau de saisie
    #################################
    //-->

    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
    <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
    </tr>
    <tr>
    <table width="850" border="1" cellspacing="0" cellpadding="0">
    <tr class="pageHeading"><br><?php echo TEXT_NEW_BUNDLE;?><br></tr>
    <?php
    // dernier numéro de bundle
    $products_bundle_model_query = tep_db_query("select products_bundle_model as order_bundle from " . TABLE_PRODUCTS_BUNDLES . " where products_bundle_model LIKE 'KD%' ORDER BY order_bundle DESC LIMIT 0,1");
    $products_bundle_req = tep_db_fetch_array($products_bundle_model_query);
    $last_products_bundle_model = $products_bundle_req['order_bundle'];
    ?>
    <tr class="main"><br><?php echo TEXT_LAST_BUNDLE; echo $last_products_bundle_model?><br><br></tr>
    <tr class="dataTableHeadingRow">
    <td class="main" width="315px"><?php echo TEXT_PRODUCTS_SELECT; ?></td>
    <td class="main" width="85px"><?php echo TEXT_SELL_PRICE_TTC; ?></td>
    <td class="main" width="85px"><?php echo TEXT_AT_PRICE_HT; ?></td>
    <td class="main" width="155px"><?php echo TEXT_BUNDLE_PRICE_TTC; ?></td>
    <td class="main" width="68px"><?php echo TEXT_BUNDLE_MARGE; ?></td>
    <td class="main" width="45px"><?php echo TEXT_BUNDLE_QUANTITY; ?></td>
    <td class="main"><?php echo TEXT_TYPE_BUNDLE; ?></td>
    </tr>
    <table width="850" border="1">
    <?php echo tep_draw_form('choix_1', FILENAME_BUNDLE, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=choix', 'post', 'enctype="multipart/form-data"'); ?>
    <tr>
    <td class="main"><?php echo tep_draw_bundle_products_pull_down('products_id', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']); ?></td>
    <td class="main" width="85px"><?php echo $products_price[1];?></td>
    <td class="main" width="80px"><?php echo $products_tarif_ha_ht_last[1]; echo tep_draw_hidden_field('products_model');?></td>
    <td class="main" width="150px"><?php echo tep_draw_input_field('products_cpta_price'); ?></td>
    <td class="main" width="65px"><?php //$marge = sprintf("%01.2f",(($products_cpta_price/$products_tarif_ha_ht_last)-1)*100);echo $marge; ?></td>
    <td class="main" width="40px"><?php echo $products_quantity[1]; echo tep_draw_hidden_field('products_cptp');?></td>
    <td class="main"><?php echo '&nbsp;' . tep_draw_radio_field('products_type','S',true) . '&nbsp;' . TEXT_SPECIAL . '&nbsp;' . tep_draw_radio_field('products_type','G') . '&nbsp;' . TEXT_GRATUIT; ?></td>
    </tr>
    </table>
    <table width="850" border="1">
    <tr>
    <td class="main"><?php echo tep_draw_bundle_products_pull_down('products_id', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']); ?></td>
    <td class="main" width="85px"><?php echo $products_price[2];?></td>
    <td class="main" width="80px"><?php echo $products_tarif_ha_ht_last[2]; echo tep_draw_hidden_field('products_model');?></td>
    <td class="main" width="150px"><?php echo tep_draw_input_field('products_cpta_price'); ?></td>
    <td class="main" width="65px"><?php //$marge = sprintf("%01.2f",(($products_cpta_price/$products_tarif_ha_ht_last)-1)*100);echo $marge; ?></td>
    <td class="main" width="40px"><?php echo $products_quantity[2]; echo tep_draw_hidden_field('products_cptp');?></td>
    <td class="main"><?php echo '&nbsp;' . tep_draw_radio_field('products_type','S',true) . '&nbsp;' . TEXT_SPECIAL . '&nbsp;' . tep_draw_radio_field('products_type','G') . '&nbsp;' . TEXT_GRATUIT; ?></td>
    </tr>
    </form>
    </table>
    <?php $products_bundle_total_price = $products_cpta_price; ?>
    <table width="850">
    <tr>
    <td class="main" width="300px"><?php echo TEXT_TOTAL_BUNDLE; ?></td>
    <td class="main" width="85px"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    <td class="main" width="70px"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    <td class="main" width="100px"><?php echo $products_bundle_total_price; ?></td>
    <td class="main" width="65px"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    <td class="main" width="45px"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr>
    </table>

  5. #5
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    mon code est-il si incompréhensible que ça sorti de son contexte ?
    Quelles précisions faudrait-il pour compléter ?

  6. #6
    Membre habitué
    Avatar de thanathz
    Inscrit en
    Mars 2002
    Messages
    147
    Détails du profil
    Informations forums :
    Inscription : Mars 2002
    Messages : 147
    Points : 178
    Points
    178
    Par défaut
    déjà les balises [ code ] pour commencer, car là c'est totalement illisible...

    Ensuite virer les morceaux de code inutile pour résoudre le problème... tu dois quand même te douter que les table, tr et autres td ne sont en aucun cas le problème...

  7. #7
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    J'ai épuré mon code. J'espère que l'on comprend encore ce que je veux faire.

    <?php
    if ($action == 'choix') {
    // récup du prix d'achat HT AT, quantité et compte compta d'un produit à partir id recu par menu déroulant
    $products_name_query = tep_db_query("select products_model, products_tarif_ha_ht_last, products_quantity, products_cptp, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
    while ($products_req = tep_db_fetch_array($products_name_query))
    {$products_model[] = $products_req['products_model'] ;
    $products_tarif_ha_ht_last[] = $products_req['products_tarif_ha_ht_last'] ;
    $products_cptp[] = $products_req['products_cptp'] ;
    $products_quantity[] = $products_req['products_quantity'] ;
    $products_price[] = $products_req['products_price'] ;
    }
    }
    ?>
    <!-- tableau de saisie
    #################################
    //-->
    <?php
    // dernier numéro de bundle
    $products_bundle_model_query = tep_db_query("select products_bundle_model as order_bundle from " . TABLE_PRODUCTS_BUNDLES . " where products_bundle_model LIKE 'KD%' ORDER BY order_bundle DESC LIMIT 0,1");
    $products_bundle_req = tep_db_fetch_array($products_bundle_model_query);
    $last_products_bundle_model = $products_bundle_req['order_bundle'];
    ?>
    <table width="850" border="1">
    <?php echo tep_draw_form('choix_1', FILENAME_BUNDLE, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=choix', 'post', 'enctype="multipart/form-data"');
    echo tep_draw_bundle_products_pull_down('products_id', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']);
    echo $products_price[0];
    echo $products_tarif_ha_ht_last[0];
    echo tep_draw_input_field('products_cpta_price');
    echo $products_quantity[0];
    echo '&nbsp;' . tep_draw_radio_field('products_type','S',true) . '&nbsp;' . TEXT_SPECIAL . '&nbsp;' . tep_draw_radio_field('products_type','G') . '&nbsp;' . TEXT_GRATUIT;
    ?>
    </table>
    <table width="850" border="1">
    <?php echo tep_draw_bundle_products_pull_down('product_2', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']);
    echo $products_price[1];
    echo $products_tarif_ha_ht_last[1];
    echo tep_draw_input_field('products_cpta_price');
    echo $products_quantity[1];
    echo '&nbsp;' . tep_draw_radio_field('products_type','S',true) . '&nbsp;' . TEXT_SPECIAL . '&nbsp;' . tep_draw_radio_field('products_type','G') . '&nbsp;' . TEXT_GRATUIT;?>
    </tr>
    </table>
    </form>
    </table>

  8. #8
    Membre émérite
    Avatar de yiannis
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    1 494
    Détails du profil
    Informations personnelles :
    Âge : 59
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 1 494
    Points : 2 791
    Points
    2 791
    Par défaut
    utilise les balises [code], comme on te l'a dit plus haut car la, c'est illisible
    "Ce besoin de remords qui précède le Mal, que dis-je ! qui le crée..." E. CIORAN

  9. #9
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    J'ai entouré mon code de balise code, si j'ai bien compris ce qu'on me demande.
    Et j'ai déjà cherché dans la FAQ et google.
    Ce doit être que la 2ème fois que je dépose sur ce forum, je dois donc m'habituer à ses usages.

    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
     
    <?php 
    if ($action == 'choix') { 
    // récup du prix d'achat HT AT, quantité et compte compta d'un produit à partir id recu par menu déroulant 
    $products_name_query = tep_db_query("select products_model, products_tarif_ha_ht_last, products_quantity, products_cptp, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); 
    while ($products_req = tep_db_fetch_array($products_name_query)) 
    {$products_model[] = $products_req['products_model'] ; 
    $products_tarif_ha_ht_last[] = $products_req['products_tarif_ha_ht_last'] ; 
    $products_cptp[] = $products_req['products_cptp'] ; 
    $products_quantity[] = $products_req['products_quantity'] ; 
    $products_price[] = $products_req['products_price'] ; 
    } 
    } 
    ?> 
    <!-- tableau de saisie 
    ################################# 
    //--> 
    <?php 
    // dernier numéro de bundle 
    $products_bundle_model_query = tep_db_query("select products_bundle_model as order_bundle from " . TABLE_PRODUCTS_BUNDLES . " where products_bundle_model LIKE 'KD%' ORDER BY order_bundle DESC LIMIT 0,1"); 
    $products_bundle_req = tep_db_fetch_array($products_bundle_model_query); 
    $last_products_bundle_model = $products_bundle_req['order_bundle']; 
    ?> 
    <table width="850" border="1"> 
    <?php echo tep_draw_form('choix_1', FILENAME_BUNDLE, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=choix', 'post', 'enctype="multipart/form-data"'); 
    echo tep_draw_bundle_products_pull_down('products_id', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']); 
    echo $products_price[0]; 
    echo $products_tarif_ha_ht_last[0]; 
    echo tep_draw_input_field('products_cpta_price'); 
    echo $products_quantity[0]; 
    echo '&nbsp;' . tep_draw_radio_field('products_type','S',true) . '&nbsp;' . TEXT_SPECIAL . '&nbsp;' . tep_draw_radio_field('products_type','G') . '&nbsp;' . TEXT_GRATUIT; 
    ?> 
    </table> 
    <table width="850" border="1"> 
    <?php echo tep_draw_bundle_products_pull_down('product_2', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']); 
    echo $products_price[1]; 
    echo $products_tarif_ha_ht_last[1]; 
    echo tep_draw_input_field('products_cpta_price'); 
    echo $products_quantity[1]; 
    echo '&nbsp;' . tep_draw_radio_field('products_type','S',true) . '&nbsp;' . TEXT_SPECIAL . '&nbsp;' . tep_draw_radio_field('products_type','G') . '&nbsp;' . TEXT_GRATUIT;?> 
    </tr> 
    </table> 
    </form> 
    </table>

  10. #10
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    Bonjour,
    Je tente de nouveau ma chance avec un code encore un peu réduit :
    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
     
    <?php 
    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
    // mise à jour table products_bundles
    if ($action == 'choix') {   
         // récup du prix d'achat HT AT, quantité et compte compta d'un produit à partir id recu par menu déroulant
          $products_name_query = tep_db_query("select products_model, products_tarif_ha_ht_last, products_quantity, products_cptp, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
         while ($products_req = tep_db_fetch_array($products_name_query))	
    	 	{$products_model[] = $products_req['products_model'] ;
    	     $products_tarif_ha_ht_last[] = $products_req['products_tarif_ha_ht_last'] ;
          	 $products_quantity[] = $products_req['products_quantity'] ;
    	  	 $products_price[] = $products_req['products_price'] ;
    		}
      }	  							 							 							 							           
    ?>
    <!-- tableau de saisie  //-->		  
    		  <table width="850" border="1">
    		  <tr>
    		  <?php echo tep_draw_form('choix_1', FILENAME_BUNDLE, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=choix', 'post', 'enctype="multipart/form-data"');
    		   	echo tep_draw_bundle_products_pull_down('products_id', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']);
    		   	echo $products_price[0];
    			echo $products_tarif_ha_ht_last[0];
    		  	echo $products_quantity[0];
    		    ?>
    		   </tr>
    		   <tr>
    		  <?php echo tep_draw_bundle_products_pull_down('product_2', 'style="width:300px" onchange="document.choix_1.submit()"', $parameters, $HTTP_GET_VARS['pID']);
    		   	echo $products_price[1];
    		   	echo $products_tarif_ha_ht_last[1];
    		   	echo $products_quantity[1]; 
    			?>
    		  </tr>
    		  </form>
    		  </table>

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 39
    Points : 31
    Points
    31
    Par défaut
    perso je ne comprend pas ce que tu veux.

  12. #12
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    je veux faire plusieurs select dans un formulaire pour sélectionner plusieurs produits et afficher leurs caractéristiques sur la même ligne que le select.
    Chaque ligne de mon tableau affiche le select et des elements (prix, quantité ..) extrait de la base.
    ça marche pour le premier produit mais Je n'arrive pas à gérer ça pour plusieurs lignes.

  13. #13
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 39
    Points : 31
    Points
    31
    Par défaut
    donc tu as un tableau tu rentres des reference des les case et apres avoir valider ton script traite et affiche les resultats ou details des produit ?

    a ce moment faut passer pas une fonction javascript pour generer des variables exemple:
    $num_ref=3;
    $ref1=xx;
    $ref2=yy;
    $ref3=zz;

    c'est un exemple mais tu peux aussi genere en javascript tes variables de telle maniere a les recuperer sous forme de tableau sous PHP, mais je ne me rappel plus comment on fait.

    a partir du moment on tu fais ca, tu devrais pouvoir traiter plusieurs element dans ton tableau.

  14. #14
    Membre du Club
    Inscrit en
    Août 2005
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Août 2005
    Messages : 78
    Points : 44
    Points
    44
    Par défaut
    Mes éléments sont déjà dans le tableau :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    while ($products_req = tep_db_fetch_array($products_name_query))	
    	 	{$products_model[] = $products_req['products_model'] ;
    	     $products_tarif_ha_ht_last[] = $products_req['products_tarif_ha_ht_last'] ;
          	 $products_quantity[] = $products_req['products_quantity'] ;
    	  	 $products_price[] = $products_req['products_price'] ;
    		}
    La où je coince c'est pour faire correspondre les éléments de ce tableau aux différents select et pour afficher dans la ligne correspondant au select

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Création d'un formulaire sous flash?
    Par ultrakas dans le forum Flash
    Réponses: 5
    Dernier message: 11/01/2005, 18h33
  2. [CR][Access] intégrer un viewer dans un formulaire access
    Par nicolak dans le forum SAP Crystal Reports
    Réponses: 7
    Dernier message: 13/01/2003, 15h52
  3. []Problème avec les formulaires Outlook
    Par davidinfo dans le forum Outlook
    Réponses: 6
    Dernier message: 05/12/2002, 09h59
  4. [VB6][Formulaire]Appliquer un Scrollbar a une Form
    Par Boil dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 09/11/2002, 03h51
  5. [CR] Tranfert de formulaire a travers une page HTMl
    Par LIEU dans le forum SAP Crystal Reports
    Réponses: 3
    Dernier message: 12/09/2002, 08h37

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