Tema: Condición
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 22/08/2013, 13:17
Avatar de mexbale
mexbale
 
Fecha de Ingreso: septiembre-2010
Ubicación: Iztapalapa
Mensajes: 146
Antigüedad: 13 años, 7 meses
Puntos: 1
Respuesta: Condición

Estimado Erick_MD9

lo que quiero hacer con esto

Código PHP:
Ver original
  1. $P04A = ($P04A==1 && $P04B==1 && $P04AC==1 && $P04D==1);
  2. if ($P04A=100)

es que compare las variables de los checkbox y si de la A a la D es 1 que valga 100 y si no es el caso que valga 0

para que me comprendas mejor tengo todo este código:

Código PHP:
Ver original
  1. <?PHP  //primera Tabla
  2. if(isset($_POST["enviar"]))
  3. {
  4.  
  5. $FOLIO = $_POST['FOLIO'] = trim($_POST['FOLIO']);
  6. $P01 = trim($_POST['P01']);
  7. if (empty($P01)){$P01='NULL';}
  8. $P02 = trim($_POST['P02']);
  9. if (empty($P02)){$P02='NULL';}
  10. $P03 = trim($_POST['P03']);
  11. if (empty($P03)){$P03='NULL';}
  12. $P04A = trim($_POST['P04A']);
  13. if (empty($P04A)){$P04A='NULL';}
  14. $P04B = trim($_POST['P04B']);
  15. if (empty($P04B)){$P04B='NULL';}
  16. $P04C = trim($_POST['P04C']);
  17. if (empty($P04C)){$P04C='NULL';}
  18. $P04D = trim($_POST['P04D']);
  19. if (empty($P04D)){$P04D='NULL';}
  20. $P04E = trim($_POST['P04E']);
  21. if (empty($P04E)){$P04E='NULL';}
  22. $P04F = trim($_POST['P04F']);
  23. if (empty($P04F)){$P04F='NULL';}
  24. $P04 = ($P04A==1 && $P04B==1 && $P04AC==1 && $P04D==1);
  25. if ($P04A=100)
  26.  
  27. $PROM=($P01+$P02+$P03+$P04)/4;
  28.  
  29.  
  30. $FOLIO = $_POST['FOLIO'] = trim($_POST['FOLIO']);
  31. $link = mysql_connect('*****', '***', '*******');
  32. if (!$link) {
  33.   die('No pudo conectarse: ' . mysql_error());
  34. }
  35. mysql_select_db('******');
  36.  
  37. $qry="INSERT INTO ***** (FOLIO, P01, P02, P03, P04, P04A, P04B, P04C, P04D, P04E, P04F, PROM)
  38. VALUES ('$FOLIO', $P01, $P02, $P03, $P04, $P04A, $P04B, $P04C, $P04D, $P04E, $P04F, '$PROM');";
  39.  
  40. mysql_query ($qry);
  41.  
  42. }
  43. ?>

Y esto es mis checkbox:

Código HTML:
Ver original
  1. <table border="1">
  2.     <tr>
  3.       <td>FOLIO</td>
  4.       <td><input type="text" name="FOLIO" id="FOLIO"></td>
  5.     </tr>
  6.   </table>
  7.   <table border="1">
  8.   <tr>
  9.     <td><input type="radio" name="P01" id="P0101" value="150" /></td>
  10.     <td></td>
  11.   </tr>
  12.   <tr>
  13.     <td><input type="radio" name="P01" id="P0102" value="0" /></td>
  14.     <td>No</td>
  15.   </tr>
  16.   </table>
  17.   <table border="1">
  18.   <tr>
  19.     <td><input type="radio" name="P02" id="P0201" value="250" /></td>
  20.     <td></td>
  21.   </tr>
  22.   <tr>
  23.     <td><input type="radio" name="P02" id="P0202" value="0" /></td>
  24.     <td>No, tuve que preguntar</td>
  25.   </tr>
  26.   </table>
  27.   <table border="1">
  28.   <tr>
  29.     <td><input type="radio" name="P03" id="P0301" value="350" /></td>
  30.     <td></td>
  31.   </tr>
  32.   <tr>
  33.     <td><input type="radio" name="P03" id="P0302" value="0" /></td>
  34.     <td>No Aplica</td>
  35.   </tr>
  36.   </table>
  37.   <table border="1">
  38.     <tr>
  39.       <td><input type="checkbox" name="P04A" id="P04A" value="1" /></td>
  40.       <td>A) Identificación válida</td>
  41.     </tr>
  42.     <tr>
  43.       <td><input type="checkbox" name="P04B" id="P04B" value="1" /></td>
  44.       <td>B) Nombre del remitente</td>
  45.     </tr>
  46.     <tr>
  47.       <td><input type="checkbox" name="P04C" id="P04C" value="1" /></td>
  48.       <td>C) Monto esperado</td>
  49.     </tr>
  50.     <tr>
  51.       <td><input type="checkbox" name="P04D" id="P04D" value="1" /></td>
  52.       <td>D) País de origen del envío del dinero</td>
  53.     </tr>
  54.     <tr>
  55.       <td><input type="checkbox" name="P04E" id="P04E" value="1" /></td>
  56.       <td>E) Número de control de la transferencia (MTCN)</td>
  57.     </tr>
  58.     <tr>
  59.       <td><input type="checkbox" name="P04F" id="P04F" value="0" /></td>
  60.       <td>Otros</td>
  61.     </tr>
  62.   </table>
  63.   <table border="1">
  64.   <tr>
  65.     <td><input type="submit" name="enviar" id="enviar" value="Enviar"></td>
  66.     <td>input type="reset" name="resett" id="resett" value="Restablecer"></td>
  67.   </tr>

y lo que quiero hacer es que si le van click a los checkbox P04A, P04B, P04C Y P04D que me de un valor de 100 y si no me seleccionan todos esos me ponga un valor null o 0

espero que si me explique y muchas gracias por tu ayuda

Buena tarde y muchas gracias