Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/194157-session-help/
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021552
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021561
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021567
Share on other sites

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 :)

Link to comment
https://forums.phpfreaks.com/topic/194157-session-help/#findComment-1021572
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.