Passing value with Hyperlink click !!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tamimmakki
    New Member
    • Nov 2007
    • 6

    Passing value with Hyperlink click !!!

    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.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by tamimmakki
    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.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

    • tamimmakki
      New Member
      • Nov 2007
      • 6

      #3
      Originally posted by markusn00b
      You'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

      :)
      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?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by tamimmakki
        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...

        Comment

        Working...