Jump to content

Insert Array Data


Dysan

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.