By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

Passing value with Hyperlink click !!!

P: 6
hi, I want to pass a value with hyperlink click to a php page.What i want to do is I have a list of 12 players in form of hyperlinks. if some user want to check profile of any player he will click on that players hyperlink, I have information of all players in database. I want that hyperlink player name in my database query to search that players profile in database.
Dec 26 '07 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
hi, I want to pass a value with hyperlink click to a php page.What i want to do is I have a list of 12 players in form of hyperlinks. if some user want to check profile of any player he will click on that players hyperlink, I have information of all players in database. I want that hyperlink player name in my database query to search that players profile in database.
You'd want to use the $_GET function.

Pass your players username (or id) through the url like so:

www.yoursite.com/some_directory/index.php?id=username_here

You'd change the bits that needed changing - the bits that are in bold ;)

On your php page, in this case it's index.php,
you'd have something like so:
[php]
<?php
$user = $_GET['id']; // GETS the string following 'id' in the url.
// execute code here
// query your db with the $user
?>
[/php]
Hope that helps :)

Also, you can pass multiple values with the url by seperating them with a &

e.g.
www.yoursite.com/somedirectory/index.php?id=username&something=blah&something_else=yeh

:)
Dec 26 '07 #2

P: 6
You'd want to use the $_GET function.

Pass your players username (or id) through the url like so:

www.yoursite.com/some_directory/index.php?id=username_here

You'd change the bits that needed changing - the bits that are in bold ;)

On your php page, in this case it's index.php,
you'd have something like so:
[php]
<?php
$user = $_GET['id']; // GETS the string following 'id' in the url.
// execute code here
// query your db with the $user
?>
[/php]
Hope that helps :)

Also, you can pass multiple values with the url by seperating them with a &

e.g.
www.yoursite.com/somedirectory/index.php?id=username&something=blah&something_else=yeh

:)
thnx mate but unfortunatly i think i was unable to explain my problem. I am not posting any form. It will be just a list of players hyperlinks. if a user clicks on a hyperlink of any players name the page should redirect to detailed profile of that player. that detailed profile is saved in database. How can i instruct database which profile it should show?
Dec 26 '07 #3

Markus
Expert 5K+
P: 6,050
thnx mate but unfortunatly i think i was unable to explain my problem. I am not posting any form. It will be just a list of players hyperlinks. if a user clicks on a hyperlink of any players name the page should redirect to detailed profile of that player. that detailed profile is saved in database. How can i instruct database which profile it should show?
Do exactly what i said...

add the usersname into a url : yoursite.com/user/?user=username

when the user clicks the url they'll be taken to : yoursite.com/user/?user=username

on the yoursite.com/user/index.php page

do this

[php]
$user = $_GET['user'];
[/php]
then do anything you have to using the variable $user...
Dec 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.