hey, i'm basically trying to use php sessions and a bit of javascript to make tabbed browsing within a web page using sessions to store the data of the different opened pages.
Problem: when i unset the first 0 index in the array (ie close the default page) it seems to wipe the other one (can't get it to add more that one anymore) from the array also
the information is held in sub array
[PHP]$_SESSION['pages'][/PHP]
each page has its own array of infomation
[PHP]$_SESSION['pages'][<pageindex>]['title' => value, 'link' => value][/PHP]
the menu down the side uses a foreach loop to echo out each of the pages and links in the ['pages'] array using
[PHP]foreach($_SESSION['pages'] as $tid => $page){...}[/PHP]
so that i can get the tab id for the page to unset it from the array
there is a link echoed for each page like so:
[HTML]<a href="menu.php?action=deletetab&tid='.$tid.'" target="menu">[/HTML]
so that when its clicked, we go to the menu page where we have the following code at the top (the menu page is self contained to do all of this)
[PHP]
switch($_REQUEST['tid']){
case "deletetab":
unset($_SESSION['pages'][$_REQUEST['tid']]);
break;
<other code for other actions>
Default:
break;
}
[/PHP]
Note: it did use to work correctly when i use a for loop to itterate through the different tabs but then this would have failed because it would after one deletion, have the wrong array id (tid) number for the pages after the one we deleted and also others wouldn't have been displayed that had a higher id number because the for loop used a count($_SESSION['pages']) function to determine how many there were and how high $i should count in the loop, but if we delete from the middle, there are less even though the id's haven't changed....they wern't all displayed! but this new way seems to delete all the data when the default one is clicked, though if you click to delete the second array object, it still leaves the first intact.
Thanks in advance!