Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Banned
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add link ID into an Array

    Hello,

    I have a page containing 5 links, each link has a different ID number at the end. (Shown in Bold)

    http://localhost/Memory.php?action=add&id=1
    http://localhost/Memory.php?action=add&id=2
    http://localhost/Memory.php?action=add&id=3
    http://localhost/Memory.php?action=add&id=4
    http://localhost/Memory.php?action=add&id=5

    Each time a link is clicked, how do I add the id at the end of each link, to an array? But, if array already contains that particular ID, how do I display a message notifying the user e.g. "Already Added!"

    Once in the array, how do I output the items in the array to the screen, along with a remove button.

    Upon clicking the remove button, how do I delete the appropriate id from the array. The remove link will be in the form of the following:

    http://localhost/Memory.php?action=delete&id=1
    http://localhost/Memory.php?action=delete&id=2
    http://localhost/Memory.php?action=delete&id=3
    http://localhost/Memory.php?action=delete&id=4
    http://localhost/Memory.php?action=delete&id=5
    Last edited by Zeater; 11-20-2007 at 09:28 PM.

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Look in the PHP manual for information on Arrays. There are plenty of ideas there.

  • #3
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Just a tip, it's not good to name pages with capitals.

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    There's nothing wrong with it.

    It's a recommendation to keep the names all lowercaps because it's easier to not get it wrong.

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    There's nothing wrong with it but it's not something you should do...?

    Sounds like there's one thing wrong with it, if you shouldn't do it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •