Dysan Posted February 15, 2008 Share Posted February 15, 2008 Hi, How do I insert data into an array, upon clicking on different links? Link Examples: add.php?name=david add.php?name=george add.php?name=lisa If all links are clicked, the array should be populated with the three names (david, george, lisa) Quote Link to comment Share on other sites More sharing options...
trq Posted February 15, 2008 Share Posted February 15, 2008 You can't click more then one link at once. Quote Link to comment Share on other sites More sharing options...
chronister Posted February 15, 2008 Share Posted February 15, 2008 <?php session_start(); if(isset($_GET['name'])) { $name = $_GET['name']; } $_SESSION['nameArray'][] = $name; // we use a session so that when we click the links and change pages, we don't lose what we have. echo '<pre>'; print_r($_SESSION['nameArray']); echo '</pre>'; ?> This works perfectly. You have to use Sessions so that you can carry the value from page to page. Even though your not actually leaving the page, once you click the link the page refreshes and without sessions, you would lose the value of the previously set var. Nate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.