xProteuSx Posted December 18, 2007 Share Posted December 18, 2007 I am trying to assign a value to a session variable by having the user click on a link. Here's the idea: I am building a glossary. On page1 the user clicks on a letter, A-Z, and this takes them to a page where all terms for the letter they select are displayed. So if they click on the letter 'C" it will take them to the 'C' page, where all terms for the letter C are. The definitions are stored in a DB, and I do not have any problems querying the DB. However, I do not know how to go about setting a session variable when they click on a letter. I want this: 1. User clicks on 'C' on page1, setting session variable to 'c' 2. Click takes them to page2 which queries the db for all terms starting with 'c' or 'C' and displays them in alphabetical order. Who do I set the variable with a mouse click on a link, then have it passed to page2? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 18, 2007 Share Posted December 18, 2007 I'm assuming your url looks something like this? www.domain.com/page.php?letter=a You could put this code at the top of the pages <?php session_start(); if (isset($_GET['letter'])){ $_SESSION['letter'] = $_GET['letter']; } ?> Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 18, 2007 Author Share Posted December 18, 2007 Right on! Thanks a bunch pocobueno1388. I have actually done this in the past, but just forgot about it! Awesome ... Quote Link to comment 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.