/    Sign up×
Community /Pin to ProfileBookmark

How to pass session variable with link

I create a page of links by querying a database and bringing up a list of businesses. Now what I want to do is have someone click on one of the links and then bring up the specific data for that business (also in the database)
How would I encode the information needed into the link I create so it can be be used to query the database.

I am assuming I have to link a session variable to each link that will be used as my primary key to query the database the 2nd time

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleNov 22.2007 — If you already know the following then my apologies.

Create your links with a query string containing the id of the business. Retrieve the value from the query string to get the data from the database. For example, if I have a table with businesses each will have it's own individual id. I will create the links to look like this

<a href="http://mydomain.com/business.php?id=123">Business 123</a>

Now, in the business.php page you can retrieve the value of id using $_GET['id']. Use that value to retrieve the data from the database.

I hope that answers your question.
×

Success!

Help @michaelh613 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...