Jump to content

[SOLVED] Give Value to a Variable via Mouse Click


xProteuSx

Recommended Posts

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?

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'];
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.