Jump to content

passing an array


hyster

Recommended Posts

$seat_s is a $var that can have multiple values depending on a form in a previous page.

 

this code works fine as is, but i need to pass the array into a 3rd page. i have no idea how to do this from the code below.

 

ive tried passing the array straight into a _post then _get on the next page but that only holds the 1st value and not all of them.

 

suggestions please.... thanks

<?php
$seat_s = $_POST['seats'];

foreach($_POST['seats'] AS $seat) {

$rowId = substr($seat, 0, 1);

$columnId = substr($seat, 1);

echo $rowId . $columnId . ", ";	

}

?>

Link to comment
Share on other sites

I'd at least consider it. All you need to do is make sure you've called session_start() before any output has been sent, then you can use a $_SESSION var like any other variable.

 

<?php
session_start();
$_SESSION['post_data_array'] = $_POST['array_element'];
?>

 

Some other script . . .

<?php
session_start();
print_r($_SESSION['post_data_array']);
?>

Link to comment
Share on other sites

thanks. that passed and echo the array.

 

next problem is how do i get the output into a format i can use in a sql query?

atm the format is [1]=>value1 [2]=>value2 [13]=>value3

 

i tried echo $_SESSION['post_data_array[1]' put the value returns as array.

 

what i need is value1 value2 value3

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.