Jump to content

Archived

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

lore_lanu

[SOLVED] PHP maze type thing...

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.

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

depending on how your code starts the maze.. you may want to change

if(empty($_SESSION['pos']))

to

if(!isset($_SESSION['pos']))

if your not setting before hand!

 

I also this has moved a little out side the ranges of "design"

Share this post


Link to post
Share on other sites

I agree completely, but I think we are done anyways. :) Thanks a ton for your help! You rock!

 

Topic Solved.

Share this post


Link to post
Share on other sites

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