Libertine Posted May 22, 2011 Share Posted May 22, 2011 Hi, I do not have a problem with specific code but rather code design/technique. I am not able to articulate the problem very well but here goes. I am building a [mostly] object oriented PHP store as a personal project to improve my PHP skills. However I'm running into some problems concerning my sorting, pagination and filtering facilities. I've tried to use $_GET to store the following: Page being viewed by the user Category (e.g. fruit or vegetables) Sort method (e.g price ascending, descending etc.) When the user clicks on a link to another page for example, I must append the page number to the URL, something like "index.php?page=2" but the other $_GET parameters are lost unless I do something like: <a href=\"index.php?cat=".$_GET['cat']."&sort=".$_GET['sort']."&page=".($this->pageNum+1)."\">Next-> </a> This means whenever there is a link or form submission I must find a way to carry over all those parameters to ensure the page and category are remembered, otherwise the user is returned to page 1 and the main category. It's a mess and has become too confusing with the introduction of other pages. Clearly, I'm doing it all wrong. $_GET parameters alone are not a good solution here, at least how I'm using them. So I ask of you, what's the correct way to store information such as page number, sorting method and category? Must I use $_SESSIONS and if so how? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/237144-_get-_post-and-_session/ Share on other sites More sharing options...
Zane Posted May 22, 2011 Share Posted May 22, 2011 If you intend on keeping this information handy then there's no harm in using sessions.. because that's the whole purpose of the superglobal. To store data within the users browser session. Quote Link to comment https://forums.phpfreaks.com/topic/237144-_get-_post-and-_session/#findComment-1218833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.