Populate an Array via Anchors/HyperLinks

Discussion in 'PHP' started by FishSword, Apr 10, 2010.

  1. #1
    Hi,

    How would I go about populating an array through anchors (<a>)?

    I have several links that contain people names, and I want to put these into an array upon the user clicking them. The data inside the array will not always be the same, it all depends on what names the user clicks on.

    Cheers ;)
     
    FishSword, Apr 10, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use a session, have the a tags link to your script along with the id of each name, then save the data in the session as an array
     
    JAY6390, Apr 10, 2010 IP
  3. FishSword

    FishSword Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    How would I code that? I've tried searching on the internet, but can't find any solution.
     
    FishSword, Apr 10, 2010 IP
  4. aTo

    aTo Active Member

    Messages:
    473
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    78
    #4
    are u using a database?
     
    aTo, Apr 10, 2010 IP
  5. FishSword

    FishSword Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    No. The names will be hard coded.
     
    FishSword, Apr 10, 2010 IP
  6. FishSword

    FishSword Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #6
    Does anybody have any Idea's on how this will be coded?
     
    FishSword, Apr 10, 2010 IP
  7. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #7
    Do you have an example? im a little lost as to what you are asking but can almost certainly give you the code you need.
     
    lukeg32, Apr 10, 2010 IP
  8. FishSword

    FishSword Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #8
    OK. Cheers Lukeg32.

    I have a page that contains a couple of links.

    Example:

    Dave James Steve Ian Kate

    
    
    <a href="#">Dave</a><a href="#">James</a><a href="#">Steve</a><a href="#">Ian</a><a href="#">Kate</a>
    
    Code (markup):
    A user clicks one of the links, how do I populate an array with the names that they have click.

    Example:

    If James and Ian's names were clicked, the array should look like the following when using print_r:

    
    Array
    {
      [0] => James
      [1] => Ian
    }
    
    Code (markup):
    Hope this helps
     
    FishSword, Apr 10, 2010 IP
  9. FishSword

    FishSword Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #9
    any ideas? :confused:
     
    FishSword, Apr 10, 2010 IP