Jump to content

[SOLVED] PHP maze type thing...


lore_lanu

Recommended Posts

if(empty($_SESSION['pos']))
{
  $_SESSION['pos'] = 0;
}else{
  $_SESSION['pos'] = $rooms[$_SESSION['pos']][$_GET['number']];
}
if(!isset($rooms[$_SESSION['pos']]))
{
echo "Room error!";//attempting to bypass rooms will cause this
exit;
}
foreach ($rooms[$_SESSION['pos']] as $K=>$roomid) {
     //$roomid isn't used but its the room your going into
     //you may use this later !!
     echo "<a href=\"?number=$K\">$roomid</a><br>";
}

 

Okay so that's what I have posted under my array. Anytime I click on one of the room ids, it should change to a different set of room ids, right? Whenever I do click, however, the url updates (ie ?number=1) but the numbers stay the same.

I did a little testing and it seems that

 

print $rooms[$_SESSION['pos']][$_GET['number']];

 

Outputs the right code but since that is the value of $_SESSION['pos'] the code

foreach ($rooms[$_SESSION['pos']] as $K=>$roomid) {

 

turns out equaling

foreach ($rooms[$rooms[$_SESSION['pos']][$_GET['number']]] as $K=>$roomid) {

 

Or something along those lines. I think that is causing problems..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.