Saving page states
Posted: Fri Oct 22, 2004 4:07 pm
I have a major design question I have been considering. I am somewhat new with PHP but I'm sure I could manage something like this with a weekend of work.
Here's what's going on: I have a web page that has expandable menus, using javascript. Under the expandable menus are links that take you to new php pages. The problem is that when you go to a new page, all of the menus reset to their old states (none of them being expanded.)
What I want to do is somehow pass information to the page I'm linking to as to what menus are expanded so I can call the functions to expand them when the page opens up.
What's the best way to do this? Send query strings, then have some if statements when a page loads checking if a query string is set and if so, execute the function to expand the menus? Would sessions or cookies work better?
Here is what I think would do as of right now:
let's say my page got sent test.php?expand=NDL
I would take that NDL and put it into an character array, where N=news, D=downloads, and L=links. Then I'd use a for loop and do something like:
Would this work? Maybe I would instead need to insert a terminating character as the last member of the array then use a While loop to pass through the array until I reached the terminating character. I'm not exactly sure how PHP's arrays work.
Any ideas on how to achieve this or tips on how to design it or code it would be appreciated!
Weirdan | Help us, help you. Please use
Here's what's going on: I have a web page that has expandable menus, using javascript. Under the expandable menus are links that take you to new php pages. The problem is that when you go to a new page, all of the menus reset to their old states (none of them being expanded.)
What I want to do is somehow pass information to the page I'm linking to as to what menus are expanded so I can call the functions to expand them when the page opens up.
What's the best way to do this? Send query strings, then have some if statements when a page loads checking if a query string is set and if so, execute the function to expand the menus? Would sessions or cookies work better?
Here is what I think would do as of right now:
let's say my page got sent test.php?expand=NDL
I would take that NDL and put it into an character array, where N=news, D=downloads, and L=links. Then I'd use a for loop and do something like:
Code: Select all
for(i=0; i<arraySize; i++){
switch(array) {
case 'N': expandNews();
case 'D': expandDownloads();
case 'L': expandLinks();
case 'T' expandTutorials();
}
}Any ideas on how to achieve this or tips on how to design it or code it would be appreciated!
Weirdan | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]