Saving variables on a click

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a menu made up of images where users can click an image to load the
next page.  I want each image to send a unique id number to the page the
user loads.  Based on this id number, the page that will be loaded will
display something different.

Since I'm not using a form to post data, I decided to save the id number as
a session variable.  The loaded page will read the variable when determining
what to load.  The problem I'm encountering is where to put the code to get
the first page to save the id number (I know how to save and retrieve
session variables, so that's not an issue).

I've tried putting the php script inside the onclick attribute of the link,
but that didn't work.  Does anyone know how I can do this, or know a better
way?  Thanks.

John Victor

Re: Saving variables on a click

Quoted text here. Click to load it

These are two different technologies, javascript and PHP cannot
interact in this way, PHP is entirely server-side so knows very little
of what the user is doing.

try altering the link that each image uses and placing a parameter on
the end:

<A href="phppage.php?pictureid=111"><img src="img111.jpg"></a>

then in the PHP on the page you go to, you can retrieve this with

Re: Saving variables on a click

I noticed that Message-ID:
contained the following:

Quoted text here. Click to load it

What's wrong with passing the variable in the URL?

<a href="display_page.php?id=1"><img src="img1.jpg"></a>

On the receiving page, the variable will be $_GET['id']

The best way to proceed would be to then get the information from a
database, based on that variable.

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: Saving variables on a click

Quoted text here. Click to load it /

What is the accepted way to share a message across multiple newsgroups?

i    h  e  a  r    v  o  i  c  e  s

Site Timeline