PHP - variable dentro de una variable

  • JakeBurgh
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 05, 2010
  • Mensajes: 5
  • Status: Offline

Nota Diciembre 3rd, 2010, 12:04 pm

Después de haber algún problema que pasa a través de dos variables entre sí, estoy seguro de su algo simple, pero necesitaba un poco de ojos frescos.

Esta es la forma en la página 1, que se maneja en la página 2
Página1:
PHP Código: [ Select ]
<?php
$fl=mysql_query("SELECT * FROM fixtures WHERE tournament='{$_POST['div']}' AND played=0", $c);
print "<table border=1><form action='page2.php?stage=0' method=post>";
while ($fx=mysql_fetch_array($fl))
{
print "<tr><td><input type=checkbox value='". $fx['fixtureid'] ."' name='match[]'></td><td>
{$fx['homename']}</td><td>v.</td><td>{$fx['awayname']}</td><td>Turn {$fx['turn']}</td></tr>";
}
print "</table>";
print "<br /><br /><input type=submit value='Continue'";
print "</form>";
?>
 
  1. <?php
  2. $fl=mysql_query("SELECT * FROM fixtures WHERE tournament='{$_POST['div']}' AND played=0", $c);
  3. print "<table border=1><form action='page2.php?stage=0' method=post>";
  4. while ($fx=mysql_fetch_array($fl))
  5. {
  6. print "<tr><td><input type=checkbox value='". $fx['fixtureid'] ."' name='match[]'></td><td>
  7. {$fx['homename']}</td><td>v.</td><td>{$fx['awayname']}</td><td>Turn {$fx['turn']}</td></tr>";
  8. }
  9. print "</table>";
  10. print "<br /><br /><input type=submit value='Continue'";
  11. print "</form>";
  12. ?>
  13.  


Página 2

Tengo que ser capaz de utilizar el valor de u $ s para volver $ m0, con 0 = $ s, por lo que en unos puntos de s será de entre 0-15 y tendrá que devolver $ m (0-15)

PHP Código: [ Select ]
$s=$_GET['stage'];
$match=$_POST['match'];
$m0=$match[0];
 
  1. $s=$_GET['stage'];
  2. $match=$_POST['match'];
  3. $m0=$match[0];
  4.  


Gracias por cualquier ayuda.
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Diciembre 3rd, 2010, 12:04 pm

  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8211
  • Loc: USA
  • Status: Offline

Nota Diciembre 3rd, 2010, 5:09 pm

No estoy seguro de que es lo que quería sin embargo. No estoy 100% seguro de haber entendido la pregunta y lo que está haciendo ahora mismo con Page 2...aquí está mi juicio persistente para ayudarle :lol:

PHP Código: [ Select ]
// This will loop through the match array
while($match) {
 
}
  1. // This will loop through the match array
  2. while($match) {
  3.  
  4. }


Si lo que está mal...

Tal vez el siguiente ayudaría a una mejor...
PHP Código: [ Select ]
$m = $match[$s]
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • Avatar de Usuario
  • Registrado: May 22, 2004
  • Mensajes: 3415
  • Loc: Richland, WA
  • Status: Offline

Nota Diciembre 3rd, 2010, 5:54 pm

PHP Código: [ Select ]
// Just for show
$m1 = "m 1";
$m2 = "m 2";
$m3 = "m 3";
$m4 = "m 4";
$m5 = "m 5";
$m6 = "m 6";
$m7 = "m 7";
$m8 = "m 8";
 
$s = 4;
 
$temp = "m".$s //m4
 
echo $$temp; // "m 4"
 
  1. // Just for show
  2. $m1 = "m 1";
  3. $m2 = "m 2";
  4. $m3 = "m 3";
  5. $m4 = "m 4";
  6. $m5 = "m 5";
  7. $m6 = "m 6";
  8. $m7 = "m 7";
  9. $m8 = "m 8";
  10.  
  11. $s = 4;
  12.  
  13. $temp = "m".$s //m4
  14.  
  15. echo $$temp; // "m 4"
  16.  
#define NULL (::rand() % 2)

Publicar Información

  • Total de mensajes en este tema: 3 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 218 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC