Stuck with Session Variable code problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adriann
    New Member
    • Aug 2006
    • 25

    Stuck with Session Variable code problem

    Hi,
    I have a page that displays Mysql query results in either "simple" or "detailed" format. The directive to display in the desired format is obtained by looking at the value of a Session variable.

    If the variable is not set, (ie: first time a search has been initiated), then "simple" mode is assumed and the session variable set accordingly.

    As part of the finished page, there is a link to advise the user to click HERE to swap-over to "detailed" display mode.

    Now, I'm stuck. How do I change a session variable from a HTML link. If I could do that, then all would have to do is perform a JS refresh on the page, and I'd be happy.

    thank you.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You cannot address the $_SESSION array from within HTML. So you could make a little snippet of PHP code that is called by clicking the HTML link. E.g.
    [html]<a href="changeses s.php">Reset format</a>"[/html]
    The PHP code for this could be something along the following lines, assuming that you hold the display status in $_SESSION['display']:
    [php]// changesess.php
    <?php
    start_session() ;
    if ($_SESSION['display'] == 'simple')
    $_SESSION['display'] = 'full';
    ?>[/php]
    Ronald :cool:

    Comment

    Working...