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.
Passing value with Hyperlink click !!!
Collapse
X
-
Tags: None
-
Originally posted by tamimmakkihi, 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.
Pass your players username (or id) through the url like so:
www.yoursite.co m/some_directory/index.php?id=us ername_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.co m/somedirectory/index.php?id=us ername&something=blah&something_else= yeh
:) -
Originally posted by markusn00bYou'd want to use the $_GET function.
Pass your players username (or id) through the url like so:
www.yoursite.co m/some_directory/index.php?id=us ername_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.co m/somedirectory/index.php?id=us ername&something=blah&something_else= yeh
:)Comment
-
Originally posted by tamimmakkithnx 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?
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...Comment
Comment