Condition if php

Condition if php - PHP - Programmation

Marsh Posté le 05-06-2008 à 10:59:39    

Bonjour, j'ai un ptit souci.
J'ai un formulaire ou l'on check les application qu'on souhaite et ou on rentre notre login :

Code :
  1. <form action="form.php" method="post" name="monform">
  2. <?php
  3.  include("../Connections/connec.php" );
  4. mysql_select_db('satisfaction')  or die('Erreur de selection '.mysql_error());
  5.  $result = mysql_query("SELECT nom_appli FROM appli" );
  6.   while ($row = mysql_fetch_array($result)) 
  7.   {
  8.   echo "<b>";
  9.   echo $row["nom_appli"];
  10.   echo " :</b>";
  11.   echo "<input type=\"checkbox\" name=\"";
  12.   echo $row["nom_appli"];
  13.   echo "\"><br>";
  14.   }
  15.   echo "</td><td align=\"right\">";
  16.   $result1 = mysql_query("SELECT nom_appli_fr FROM appli_fr" );
  17.   while ($row = mysql_fetch_array($result1)) 
  18.   {
  19.   echo "<b>";
  20.   echo $row["nom_appli_fr"];
  21.   echo " :</b>";
  22.   echo "<input type=\"checkbox\" name=\"";
  23.   echo $row["nom_appli_fr"];
  24.   echo "\"><br>";
  25.   }
  26.   echo "</td>";
  27.   mysql_close();
  28.  ?>
  29.      </tr>
  30.      </table>
  31.      <br><br>
  32.      <p align="center"><input name="login" type="text" />
  33.      <br>
  34.      <button style="cursor:hand; background:navy; color:white; border:solid 1px black;" type="submit">Commencer</button></p>
  35.             </form>


et ensuite cela l'envoi vers un autre formulaire qui doit recuperer les application checké par l'utilisateur :

Code :
  1. <form action="Add.php" method="post" name="monform2" onsubmit="return donneavis()">
  2. <?php
  3.   include("../Connections/connec.php" );
  4. mysql_select_db('satisfaction')  or die('Erreur de selection '.mysql_error());
  5. $result = mysql_query("SELECT nom_appli FROM appli" );
  6.   while ($row = mysql_fetch_array($result)) 
  7.   {
  8.   if(document.monform.$row["nom_appli"].checked==true)
  9.   {
  10.  echo "Pour l'application <b>";
  11.  echo $row["nom_appli"];
  12.  echo "</b> vous êtes :<br><br>";
  13.  echo "<table width=\"600\">
  14.  <tr>
  15.  <td align=\"center\">";
  16.  echo "
  17.  <button style=\"cursor:hand; background:crimson; color:white; border:solid 1px black;\" type=\"button\" disabled >Très insatisfait</button>
  18.  </td>";
  19.  echo "<td align=\"center\">
  20.  <button style=\"cursor:hand; background:firebrick; color:white; border:solid 1px black;\" type=\"button\" disabled >Insatisfait</button>
  21.  </td>";
  22.  echo "<td align=\"center\">
  23.  <button style=\"cursor:hand; background:tan; color:white; border:solid 1px black;\" type=\"button\" disabled >Moyen</button>
  24.  </td>";
  25.  echo "<td align=\"center\">
  26.  <button style=\"cursor:hand; background:greenyellow; color:white; border:solid 1px black;\" type=\"button\" disabled >Bien</button>
  27.  </td>";
  28.  echo "<td align=\"center\">
  29.  <button style=\"cursor:hand; background:forestgreen; color:white; border:solid 1px black;\" type=\"button\" disabled >Exellent</button>
  30.  </td>";
  31.  echo "<td align=\"center\">
  32.  <button style=\"cursor:hand; background:grey; color:white; border:solid 1px black;\" type=\"button\" disabled >Non utilisé</button>";
  33.  echo "</td>
  34.  </tr>
  35.  <tr>";
  36.  echo "<td align=\"center\">
  37.  <input type=\"radio\" value=\"1\" name=\"";
  38.  echo $row["nom_appli"];
  39.  echo "\"></td>";
  40.  echo "<td align=\"center\">
  41.  <input type=\"radio\" value=\"2\" name=\"";
  42.  echo $row["nom_appli"];
  43.  echo "\"></td>";
  44.  echo "<td align=\"center\">
  45.  <input type=\"radio\" value=\"3\" name=\"";
  46.  echo $row["nom_appli"];
  47.  echo "\"></td>";
  48.  echo "<td align=\"center\">
  49.  <input type=\"radio\" value=\"4\" name=\"";
  50.  echo $row["nom_appli"];
  51.  echo "\"></td>";
  52.  echo "<td align=\"center\">
  53.  <input type=\"radio\" value=\"5\" name=\"";
  54.  echo $row["nom_appli"];
  55.  echo "\"></td>";
  56.  echo "<td align=\"center\">
  57.  <input type=\"radio\" value=\"NULL\" name=\"";
  58.  echo $row["nom_appli"];
  59.  echo "\"></td>";
  60.  echo "</tr>
  61.  </table>
  62.  <br>";
  63.  }
  64.  }


Voila, c'est a mon avis cette ligne la qui plante :

Code :
  1. if(document.monform.$row["nom_appli"].checked==true)


Cela ne doit pas etre la bonne syntaxe, il me met aucune erreur, mais le probleme c'est qu'il me met toutes les applications alors que je ne les ait pas toutes coché au formulaire precedent  :??:  
 

Reply

Marsh Posté le 05-06-2008 à 10:59:39   

Reply

Marsh Posté le 05-06-2008 à 11:26:19    

tu mélanges js et php donc normal que ça ne marche pas

Reply

Marsh Posté le 05-06-2008 à 11:33:59    

Oui c bon j'ai trouvé merci quand meme. :jap:  
 
PS : Je savais que c'etait du javascript mais je savais pas le remplacer par du php  
 
La solution c'est :

Code :
  1. if(isset($_POST[$row["nom_appli"]]))

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed