PHP - Variable within a variable

  • JakeBurgh
  • Newbie
  • Newbie
  • JakeBurgh
  • Posts: 5

Post 3+ Months Ago

Having some problem passing two variables through each other, I'm sure it's something simple, but needed some fresh eyes.

This is the form on page 1, which is then handled on page 2
Page1:
PHP Code: [ 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.  


Page 2

I need to be able to use the value of '$s' to return $m0, with 0=$s, so at some points $s will be between 0-15 and will need to return $m(0-15)

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


Thanks for any help.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

I'm not sure that is what you wanted though. I'm not 100% sure I understood the question and what you are doing right now with Page 2... here is my persistent trial to help you :lol:

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


If that is wrong...

Maybe the following would help better...
PHP Code: [ Select ]
$m = $match[$s]
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

PHP Code: [ 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.  

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 54 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.