assigning value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

assigning value

Post by speedy33417 »

Quick question.

How do you assign value to a variable based on which link the user clicks.

Say I have three links that point to one.php, two.php, three.php
When the user clicks on any of those links I want assign the number of that page to a variable before going to that page.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Assign it to a variable where? PHP won't be run until the page is requested.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Maybe we could offer some suggestions if you told us what you're trying to accomplish
User avatar
gkwhitworth
Forum Commoner
Posts: 85
Joined: Tue Sep 05, 2006 8:28 pm
Location: Wasilla, Alaska

Post by gkwhitworth »

yeah that is kinda finicky....feyd is right. Give a little more detail of why they are clicking these links (view database info, log into an area, view a gallery) so we can have some kind of idea why you want to assign values to the links.

--
Greg
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

Post by speedy33417 »

One of the pages where I would use it is a photo gallery page. Clicking on a thumbpic would save the album_id in a variable then process the page based on that variable.
album_view.php checks if there's a value assigned to the variable. If not that means it will display the main gallery, if there's a value assigned to it then it will display that sub-gallery.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I am not sure what you need codewise to accomplish that as I don't quite understand how you intend for it to work. Generally the variable would be set by the receiving script.
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

Post by speedy33417 »

Well, that's exactly what my problem was. I already had to have the variable assigned to some value by the time I get to the receiving page.
I'll probably just use this code.

Code: Select all

<a href=\"album_view.php?page=$album\">
Post Reply