Jump to content

[SOLVED] Passing array to another page


Zergman

Recommended Posts

I got a select box as follows

<select name="validmenu[]" class="inputbox" id="validmenu" size="3" multiple>
          <option value="*Valid*">*Valid*</option>
          <option value="Behaviour">Behaviour</option>
          <option value="Improper Abstract">Improper Abstract</option>
          <option value="Improper Route">Improper Route</option>
          <option value="Invalid STN">Invalid STN</option>
          <option value="Kudos">Kudos</option>
          <option value="Other">Other</option>
          <option value="Policy/Procedure">Policy/Procedure</option>
          <option value="Poor Ticket Creation">Poor Ticket Creation</option>
          <option value="Troubleshooting">Troubleshooting</option>
        </select>

 

Thanks to the awesome help from the people on the boards, I have it comma separated.

if (isset($_GET['validmenu'])) {
    $comma_separated = "'" . implode("','", $valid) . "'";
} else {
    $comma_separated = "'default'"; // or maybe some default value,  like "'default'"
}

 

I tried the following example I found but it didn't work.

<a href="sample2.php?<? for ($I=0, $I<count($array); $I++) echo
"array[]={$array[$I]}&"; ?>">

 

How would I use a session variable to pass the array data to another page?

First make sure you have session_start() as the first line of all pages that dealsw with sessions.

Then use the following to assign the $comma_separated variable to your session.

$_SESSION['comma_separated'] = $comma_separated;

 

Now in the next page use $_SESSION['comma_separated'] to retrieve the comma separated list.

 

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.