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.

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.