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) Link to comment https://forums.phpfreaks.com/topic/91173-insert-array-data/ 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. Link to comment https://forums.phpfreaks.com/topic/91173-insert-array-data/#findComment-467266 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 Link to comment https://forums.phpfreaks.com/topic/91173-insert-array-data/#findComment-467469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.