Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1424 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Mauvaise syntaxe php?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Mauvaise syntaxe php?

n°1848665
absot77
Posté le 08-02-2009 à 19:02:11  profilanswer
 

Slt, je pense que je vais mal coder ma page parce que je fais un formulaire et celon ce que choisit l'utilisateur, ça doit renvoyer sur un tableau diférent (1 choix, 2 possibilités) et le problème est que les deux tableau s'affiche en cochant n'importe quel choix, comment ça se fait, où est l'erreur svp?
 
Je vous montre mon code:
 
1ère page (remplissage du formulaire pour l'emreunt):

Code :
  1. <html>
  2. <head>
  3. <title>Formulaire de saisie de l'emprunt</title>
  4. <link rel="stylesheet" type="text/css" href="style.css">
  5. </head>
  6. <body>
  7. <style>
  8. h1 {font-family:freesherif;font-size:15pt;color:black;font-style:bold;text-decoration:underline}
  9. h2 {font-family:freesherif;font-size:32pt;color:black;font-style:bold;text-align:center;}
  10. </style>
  11. <form action="tableau_amortissement.php" method="POST">
  12. <TABLE BORDER="2">
  13.   <CAPTION> <h2>Formulaire de saisie de l'emprunt</h2> </CAPTION>
  14. <br/>
  15. <br/>
  16.  
  17.         <TR>
  18.     <TH> <h1> Quelle somme voulez-vous emprunter? </h1> </TH>
  19.     <TH>
  20.     <INPUT type=text name="montant" class="marge">
  21.     </TH>
  22.     <TD>&euro;</TD> 
  23.     </TR>
  24.         <TR>
  25.     <TH> <h1>Quel est le taux de votre emprunt?</h1> </TH>
  26.     <TD>
  27.     <INPUT type=text name="taux" class="marge">
  28.     </TD>
  29.     <TD>%</TD>
  30.     </TR>
  31.         <TR>
  32.  <TH><h1>Choisissez votre remboursement</h1></TH>
  33.  <TH><input type="radio" name="remboursement" value="1" />Remboursement constant<br/>
  34.   <input type="radio" name="remboursement" value="2" />Versement constant</TH>
  35.  </TR>
  36.  <TR>
  37.     <TH> <h1>A partir de quelle date commence votre emprunt?</h1> </TH>
  38.     <TD>
  39.     <select name="jour">
  40.  <?php  for ( $i=1; $i<=31; $i++ ) {
  41.   echo "<option value=$i>$i</option>";
  42.              }  ?>
  43.                    </SELECT>
  44.                                                    
  45.                  
  46.                    <SELECT name="mois">
  47.         <?php  $mois=array( "", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" );
  48.               for ($numero=1; $numero<=12; $numero++ )
  49.              {
  50.              echo "<option value=$numero>$mois[$numero]</option>";
  51.       } ?>
  52.             </SELECT>
  53.             <SELECT name="annee">
  54.         <?php 
  55.               for ($an=1900; $an<=2009; $an++ )
  56.               {
  57.               echo "<option value=$an>$an</option>";
  58.        } ?>
  59.             </SELECT>
  60.     </TD>
  61.     </TR>
  62.  
  63.  
  64.     <TR>
  65.     <TH> <h1>Quelle est la dur&eacute;e de l'emprunt?</h1> </TH>
  66.     <TD>
  67.     <INPUT type=text name="duree">
  68.     </TD>
  69.     <TD>
  70.     <SELECT name="type_duree">
  71.  <OPTION VALUE=1>mois</OPTION>
  72.  <OPTION VALUE=12>ann&eacute;e(s)</OPTION>
  73.  </SELECT>
  74.     </TD>
  75.     </TR>
  76.  
  77.  
  78.     <TR>
  79.     <TH> <h1>Quelle est votre p&eacute;riodicit&eacute;e pour l'emprunt?</h1> </TH>
  80.  <TD><SELECT name="periodicite">
  81.  <OPTION VALUE=1>mensuel</OPTION>
  82.  <OPTION VALUE=3>trimestriel</OPTION>
  83.  <OPTION VALUE=6>semestriel</OPTION>
  84.  <OPTION VALUE=12>annuel</OPTION>
  85.  </SELECT></TD>
  86.     </TR>
  87. </table>
  88. <table>
  89.     <TR>
  90.     <TD COLSPAN=2>
  91.     <INPUT type="submit" value="Envoyer">
  92.     </TD>
  93.         </TR>
  94. </table>
  95. </FORM>
  96. </body>
  97. </html>


 
2ème page (la récupération et tratement):

Code :
  1. <html>
  2. <head>
  3. <title>Tableau d'amortissement</title>
  4. <link rel="stylesheet" type="text/css" href="style.css">
  5. </head>
  6. <?php
  7. $montant= $_POST['montant'];
  8. $taux=$_POST['taux'];
  9. $jour=$_POST['jour'];
  10. $mois=$_POST['mois'];
  11. $annee=$_POST['annee'];
  12. $duree=$_POST['duree']*$_POST['type_duree'];
  13. $periodicite=$_POST['periodicite'];
  14. $remboursement=$_POST["remboursement"];
  15. ?>
  16. <body>
  17. <CAPTION><h1>Tableau d'amortissement de l'emprunt</h1></CAPTION>
  18. <TABLE BORDER="2">
  19.  
  20.     <TR>
  21. <TH> <h1> Somme emprunt&eacute;e </h1> </TH>
  22. <td><? echo $montant ."&euro;" ?></td>
  23. </TR>
  24.     <TR>
  25. <TH> <h1> Taux de l'emprunt</h1> </TH>
  26. <td><? echo $taux . "%" ?></td>
  27. </TR>
  28.     <TR>
  29. <TH> <h1>D&eacute;but de l'emprunt</h1> </TH>
  30. <TD><? echo $jour . $mois . $annee ?></TD>
  31. </TR>
  32.  
  33.  
  34. <TR>
  35. <TH> <h1> Dur&eacute;e de l'emprunt</h1> </TH>
  36. <TD><? echo $duree." mois" ?></TD>
  37. </TR>
  38.  
  39.  
  40. <TR>
  41. <TH> <h1>P&eacute;riodicit&eacute;e de l'emprunt</h1> </TH>
  42. <TD><? echo $periodicite." mois" ?></TD>
  43. </TR>
  44.   
  45.    
  46. </TABLE>
  47. <br/>
  48. <br/>
  49. <br/>
  50. <? (if $remboursement == "1" ) { ?>
  51. <TABLE BORDER="2">
  52. <tr>
  53. <th width="50px">Num&eacute;ro</th>
  54. <th width="60px">Base</th>
  55. <th width="120px">Remboursement</th>
  56. <th width="60px">Cumul</th>
  57. <th width="60px">VNC</th>
  58. <th>Int&ecirc;ret</th>
  59. <th>Versement</th>
  60. </tr>
  61. <?php
  62. // calculs de première ligne  
  63. //--> initialisation
  64. $i=1;
  65. $base=$montant;
  66. $cuml=0;
  67. $kr=$montant;
  68. // montant d'un remboursement
  69. $nbr=$duree/$periodicite;
  70. $remb=round($montant/$nbr,2);
  71. // taux périoduque
  72. $taux_p=$taux/12*$periodicite;
  73. //--> calculs complémentaires de première ligne
  74. $cumul=$cumul+$remb;
  75. $kr=$kr-$remb;
  76. $int=round($base*$taux_p,2);
  77. $vers=round($remb+$int,2);
  78. echo"
  79. <tr>
  80. <td>".$i."</td>
  81. <td>".$base."</td>
  82. <td>".$remb."</td>
  83. <td>".$cumul."</td>
  84. <td>".$kr."</td>
  85. <td>".$int."</td>
  86. <td>".$vers."</td>
  87. </tr>";
  88. for ($i=2;$i<$nbr;$i++) {
  89. $base=$kr;
  90. $cumul=$cumul+$remb;
  91. $kr=$kr-$remb;
  92. $int=$base*$taux_p;
  93. $vers=$remb+$int;
  94. echo"
  95. <tr>
  96. <td>".$i."</td>
  97. <td>".$base."</td>
  98. <td>".$remb."</td>
  99. <td>".$cumul."</td>
  100. <td>".$kr."</td>
  101. <td>".$int."</td>
  102. <td>".$vers."</td>
  103. </tr>";
  104. }
  105. // calculs et affichage de dernière ligne
  106. $base=$kr;
  107. $remb=$base;
  108. $cumul=$cumul+$remb;
  109. $kr=$kr-$remb;
  110. $int=$base*$taux_p;
  111. $vers=$remb+$int;
  112. echo"
  113. <tr>
  114. <td>".$i."</td>
  115. <td>".$base."</td>
  116. <td>".$remb."</td>
  117. <td>".$cumul."</td>
  118. <td>".$kr."</td>
  119. <td>".$int."</td>
  120. <td>".$vers."</td>
  121. </tr>";
  122. ?>
  123. </TABLE>
  124. <? }
  125. else
  126. { ?>
  127. <TABLE BORDER="2">
  128. <tr>
  129. <td>Ann&eacute;e</td>
  130. <td>Base</td>
  131. <td>Remboursement</td>
  132. <td>Cumul</td>
  133. <td>Capital restant</td>
  134. <td>Interêts</td>
  135. <td>Versement</td>
  136. </tr>
  137. </TABLE>
  138. <? } ?>
  139. </body>
  140. </html>

mood
Publicité
Posté le 08-02-2009 à 19:02:11  profilanswer
 

n°1848813
PierreC
Posté le 09-02-2009 à 10:00:21  profilanswer
 

(if $remboursement == "1" )  


 
ca serait pas plutot :

if ($remboursement == "1" )


---------------
Du tofu en Alsace : www.tofuhong.com

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Mauvaise syntaxe php?

 

Sujets relatifs
[MySQL] erreur de syntaxe ...[Résolu] Syntaxe de CSS sous IE et Firefox
Quelle syntaxe?Syntaxe inconnu demande information
template syntaxeSyntaxe INSERT INTO
Erreur :1064 Erreur de syntaxe près desyntaxe pour passage variables Java -> Flash
Requête SQL ORDER BY... syntaxeexemple syntaxe dictionnaire des données oracle
Plus de sujets relatifs à : Mauvaise syntaxe php?


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR