jac.kock Posted May 5, 2012 Share Posted May 5, 2012 hi all, i have been struckling with this code of mine i want when i click a link to change the setting for the menu (see code) <? echo "[".$_SESSION['menu']."]"; ?> <table class="border_test"> <tr> <td valign="top" align="left"> <!-- menu items: menu --> <img src="../design/item.png" width="10" height="10"><a href="<?=$_SERVER['REQUEST_URI'];?>" onclick="<? $_SESSION['menu']=1;?>"><b> Site menu:</b></a> </td> </tr> <? if($_SESSION['menu']==1) { echo ' <tr> <td> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=add_menu">Toevoegen menu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=edit_menu">Bewerken menu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=del_menu">Verwijderen menu item.</a> </td> </tr>'; } ?> <tr> <td> <!-- menu items: submenu --> <img src="../design/item.png" width="10" height="10"><a href="<?=$_SERVER['REQUEST_URI'];?>" onclick="<? $_SESSION['menu']=2;?>"><b> Site submenu:</b></a> </td> </tr> <? if($_SESSION['menu']==2) { echo ' <tr> <td> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=add_submenu">Toevoegen submenu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=edit_submenu">Bewerken submenu item.</a><br> <img src="../design/subitem.png" width="10" height="10"> <a href="?topic=del_submenu">Verwijderen submenu item.</a> </td> </tr>'; } ?> <tr> <td> <!-- menu items: Pagina's --> <img src="../design/item.png" width="10" height="10"><a href="<?=$_SERVER['REQUEST_URI']; ?>"><b> Pagina's:</b></a> </td> </tr> </table> so what it wil do is show the subitem list of the main menu item when de var is changed! butt when i use it it always set to the last ( in this case to: 2 ) even when i click the first link to set it to 1 can somebody help me to get it to work? thnx, Quote Link to comment https://forums.phpfreaks.com/topic/262117-cant-get-it-to-work-why/ Share on other sites More sharing options...
MMDE Posted May 5, 2012 Share Posted May 5, 2012 Why are you using session? Maybe you want to use $_GET? but then you need to change the urls to "?menu=1" or "?menu=2", instead of $_SERVER['REQUEST_URI']. Of course also use $_GET instead of $_SESSION! Quote Link to comment https://forums.phpfreaks.com/topic/262117-cant-get-it-to-work-why/#findComment-1343285 Share on other sites More sharing options...
jac.kock Posted May 5, 2012 Author Share Posted May 5, 2012 Why are you using session? because i thought it was handy in the main index i use session_start() suggestions? thnx Quote Link to comment https://forums.phpfreaks.com/topic/262117-cant-get-it-to-work-why/#findComment-1343286 Share on other sites More sharing options...
MMDE Posted May 5, 2012 Share Posted May 5, 2012 Why are you using session? because i thought it was handy in the main index i use session_start() suggestions? thnx Might be something I'm missing, but I honestly don't see how you set or change the session data. Some of your code is missing. You could do as I said, use GET to fetch the change and then use it to set the session data. Quote Link to comment https://forums.phpfreaks.com/topic/262117-cant-get-it-to-work-why/#findComment-1343287 Share on other sites More sharing options...
jac.kock Posted May 5, 2012 Author Share Posted May 5, 2012 Why are you using session? because i thought it was handy in the main index i use session_start() suggestions? thnx Might be something I'm missing, but I honestly don't see how you set or change the session data. Some of your code is missing. You could do as I said, use GET to fetch the change and then use it to set the session data. oke any suggestions to make it work what i want to do?? any examples?? thnx Quote Link to comment https://forums.phpfreaks.com/topic/262117-cant-get-it-to-work-why/#findComment-1343288 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.