Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/09/2008, 14:32
AlvaroX
 
Fecha de Ingreso: septiembre-2008
Mensajes: 242
Antigüedad: 15 años, 7 meses
Puntos: 3
¿que hago mal?

tengo un archivo de texto asi:

habitaciones.txt:

0011-1
0012-0
0013-0
0014-1
0015-1
0016-0
0017-0
0018-0
0019-1
0020-0

___________________

para que se ubiquen mas o menos 00XX es la habitacion y -X es su estado (ocupado o no)

y tengo un archivo php asi:

estado.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. $ph = $_POST['habitacion']; //aca se obiente 00XX
  4. $pe = $_POST['estado']; //aca se obtiene -X
  5. $p = "$ph$pe";
  6.  
  7. $ar = "habitaciones.txt";
  8. $fil = file($ar);
  9. $count = count($fil);
  10. $ary = array("-0", "-1");
  11.  
  12. for ($i=0;$i<$count;$i++)
  13. {
  14. $hab = trim(str_replace($ary, "",$fil[$i]));
  15. $es = substr($fil[$i], 4);
  16. $habits1 = "$hab$es";
  17.  
  18. if($habits1 == $p)
  19. {
  20. $habits = "$habits1";
  21. }
  22.  
  23.  
  24. }
  25.  
  26. echo $habits;
  27.  
  28. ?>

el problem es que $habtis no me da un valor

Última edición por AlvaroX; 20/09/2008 a las 15:16