herghost Posted March 4, 2010 Share Posted March 4, 2010 Hi all, I am trying to display certain data in a side panel depending on what is being displayed in the body divs. I have an ajax script which displays links form a header in the body divs Basically I am trying this: Currently Displayed in my body divs is the page viewcustomer.php, I have in this page: $display = '1'; $_SESSION['display']=$display ; So this should save the session 'display' as the value 1, correct? Now in my lpanel.php the sidepanel, I want to display the link for adding new customers so I have this: <?php if( $_SESSION['display'] = 1 ) { ?> <a href="javascript:ajaxpage('addcustomer.php', 'body');"><span><img src="images/user_add.gif" /> Add Customer</span></a> <?php } ?> However this does not work. Basically the link is always shown, eve if I change the = to 2 or 0 What am I doing wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/ Share on other sites More sharing options...
ferdi Posted March 4, 2010 Share Posted March 4, 2010 Did you remember too use session_start() at the the if the script? Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021549 Share on other sites More sharing options...
herghost Posted March 4, 2010 Author Share Posted March 4, 2010 Its set in my header.php so no need. Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021550 Share on other sites More sharing options...
AngelG107 Posted March 4, 2010 Share Posted March 4, 2010 <?php if( $_SESSION['display'] == 1 ) { // this is a PHP comment, // the display variable in the session is equal to 1 echo "<a href=\"javascript:ajaxpage('addcustomer.php', 'body');\"><span><img src=\"images/user_add.gif\" /> Add Customer</span></a>"; } ?> I guess you meant to try out the '==' instead of '=', not to mention if you want to print a string to the browser you have to use either the echo function or the print function. The echo function is faster than the print function though. Regards. Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021552 Share on other sites More sharing options...
herghost Posted March 4, 2010 Author Share Posted March 4, 2010 Thanks, However the whole idea doesnt work as addcustomer.php has to be called to set the session, and the lpanel.php is constantly shown so no refresh for it to pick up the session! Any ideas for an alternative? Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021558 Share on other sites More sharing options...
AngelG107 Posted March 4, 2010 Share Posted March 4, 2010 Alright you could something like this : $display = '1'; $_SESSION['display']=$display ; echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=http://www.example.com/lpanel.php\">"; Remember to change your domain name and all that so it works properly, that's going to refresh the page after the session changes. Regards. Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021561 Share on other sites More sharing options...
herghost Posted March 4, 2010 Author Share Posted March 4, 2010 no good unfortantly, redirects to lpanel.php. Basically My home.php looks like this: <?php session_start(); include('../config/connect.php'); ?> <div id="container"> <div id="header"><?php include('header.php'); ?> </div> <div id="navigation"><?php include('links.php'); ?> </div> <div id="body-container"> <div id="body"></div> <div id="leftpanel"><?php include('lpanel.php');?></div> </div> </div> Once you click on a link in links.php, it appears in the body div, so my browser always shows home.php, regardless of what link you click on. Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021567 Share on other sites More sharing options...
AngelG107 Posted March 4, 2010 Share Posted March 4, 2010 $display = '1'; $_SESSION['display']=$display ; echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=http://www.example.com/home.php\">"; Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021571 Share on other sites More sharing options...
herghost Posted March 4, 2010 Author Share Posted March 4, 2010 Can't do that either! Basically that would take me back to home with no page loaded. I need something that will update lpanel seperatlay in the background, say have it check for a session every second, which probably leaves me with ajax, however have no idea how to go about that! Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021572 Share on other sites More sharing options...
AngelG107 Posted March 4, 2010 Share Posted March 4, 2010 I'm sorry but I have no experience with AJAX or Javascript. I tried to help anyways. Regards. Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021575 Share on other sites More sharing options...
herghost Posted March 4, 2010 Author Share Posted March 4, 2010 No probs, thanks for looking Quote Link to comment https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021579 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.